@@ -209,14 +209,15 @@ static Instruction *cloneInstructionInExitBlock(
209209static void eraseInstruction (Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
210210 MemorySSAUpdater &MSSAU);
211211
212- static void moveInstructionBefore (Instruction &I, BasicBlock::iterator Dest,
213- ICFLoopSafetyInfo &SafetyInfo,
214- MemorySSAUpdater &MSSAU, ScalarEvolution *SE);
212+ static void moveInstructionBefore (
213+ Instruction &I, BasicBlock::iterator Dest, ICFLoopSafetyInfo &SafetyInfo,
214+ MemorySSAUpdater &MSSAU, ScalarEvolution *SE,
215+ MemorySSA::InsertionPlace Point = MemorySSA::BeforeTerminator);
215216
216217static bool sinkUnusedInvariantsFromPreheaderToExit (
217218 Loop *L, AAResults *AA, ICFLoopSafetyInfo *SafetyInfo,
218219 MemorySSAUpdater &MSSAU, ScalarEvolution *SE, DominatorTree *DT,
219- SinkAndHoistLICMFlags &SinkFlags);
220+ SinkAndHoistLICMFlags &SinkFlags, OptimizationRemarkEmitter *ORE );
220221
221222static void foreachMemoryAccess (MemorySSA *MSSA, Loop *L,
222223 function_ref<void (Instruction *)> Fn);
@@ -550,7 +551,7 @@ bool LoopInvariantCodeMotion::runOnLoop(Loop *L, AAResults *AA, LoopInfo *LI,
550551 // pressure.
551552 Flags.setIsSink (true );
552553 Changed |= sinkUnusedInvariantsFromPreheaderToExit (L, AA, &SafetyInfo, MSSAU,
553- SE, DT, Flags);
554+ SE, DT, Flags, ORE );
554555
555556 if (VerifyMemorySSA)
556557 MSSA->verifyMemorySSA ();
@@ -1468,15 +1469,14 @@ static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
14681469
14691470static void moveInstructionBefore (Instruction &I, BasicBlock::iterator Dest,
14701471 ICFLoopSafetyInfo &SafetyInfo,
1471- MemorySSAUpdater &MSSAU,
1472- ScalarEvolution *SE ) {
1472+ MemorySSAUpdater &MSSAU, ScalarEvolution *SE,
1473+ MemorySSA::InsertionPlace Point ) {
14731474 SafetyInfo.removeInstruction (&I);
14741475 SafetyInfo.insertInstructionTo (&I, Dest->getParent ());
14751476 I.moveBefore (*Dest->getParent (), Dest);
14761477 if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
14771478 MSSAU.getMemorySSA ()->getMemoryAccess (&I)))
1478- MSSAU.moveToPlace (OldMemAcc, Dest->getParent (),
1479- MemorySSA::BeforeTerminator);
1479+ MSSAU.moveToPlace (OldMemAcc, Dest->getParent (), Point);
14801480 if (SE)
14811481 SE->forgetBlockAndLoopDispositions (&I);
14821482}
@@ -1487,7 +1487,7 @@ static void moveInstructionBefore(Instruction &I, BasicBlock::iterator Dest,
14871487static bool sinkUnusedInvariantsFromPreheaderToExit (
14881488 Loop *L, AAResults *AA, ICFLoopSafetyInfo *SafetyInfo,
14891489 MemorySSAUpdater &MSSAU, ScalarEvolution *SE, DominatorTree *DT,
1490- SinkAndHoistLICMFlags &SinkFlags) {
1490+ SinkAndHoistLICMFlags &SinkFlags, OptimizationRemarkEmitter *ORE ) {
14911491 BasicBlock *ExitBlock = L->getExitBlock ();
14921492 if (!ExitBlock)
14931493 return false ;
@@ -1536,7 +1536,7 @@ static bool sinkUnusedInvariantsFromPreheaderToExit(
15361536 continue ;
15371537
15381538 moveInstructionBefore (I, ExitBlock->getFirstInsertionPt (), *SafetyInfo,
1539- MSSAU, SE);
1539+ MSSAU, SE, MemorySSA::Beginning );
15401540 MadeAnyChanges = true ;
15411541 }
15421542
0 commit comments