@@ -413,18 +413,17 @@ void AIEBaseHardwareLoops::expandLoopStart(LowOverheadLoop &LoLoop) {
413413 TII->get (LoweringData->SetLoopCountOpcode ), LoweringData->LCRegister )
414414 .addReg (Start->getOperand (0 ).getReg ())
415415 .addImm (Start->getOperand (1 ).getImm ());
416-
417- BuildMI (*MBB, Start, Start->getDebugLoc (),
418- TII->get (LoweringData->SetAddressOpcode ), LoweringData->LSRegister )
419- .addMBB (LoLoop.LoopEnd ->getOperand (1 ).getMBB ());
420- MachineInstrBuilder MIB;
421- MIB = BuildMI (*MBB, Start, Start->getDebugLoc (),
422- TII->get (LoweringData->SetAddressOpcode ),
423- LoweringData->LERegister )
424- .addSym (LoLoop.LoopEnd ->getOperand (0 ).getMCSymbol ());
425- MachineInstr *MI = MIB.getInstr ();
426- MI->getOperand (1 ).ChangeToMCSymbol (
427- LoLoop.LoopEnd ->getOperand (0 ).getMCSymbol ());
416+ auto LoopStart = BuildMI (*MBB, Start, Start->getDebugLoc (),
417+ TII->get (LoweringData->SetLoopStartOpcode ));
418+ if (LoweringData->LSRegister )
419+ LoopStart.addDef (*LoweringData->LSRegister );
420+ LoopStart.addMBB (LoLoop.LoopEnd ->getOperand (1 ).getMBB ());
421+
422+ auto LoopEnd = BuildMI (*MBB, Start, Start->getDebugLoc (),
423+ TII->get (LoweringData->SetLoopEndOpcode ));
424+ if (LoweringData->LERegister )
425+ LoopEnd.addDef (*LoweringData->LERegister );
426+ LoopEnd.addSym (LoLoop.LoopEnd ->getOperand (0 ).getMCSymbol ());
428427
429428 LoLoop.remove (LoLoop.Start );
430429}
0 commit comments