@@ -911,13 +911,15 @@ bool llvm::hoistRegion(DomTreeNode *N, AAResults *AA, LoopInfo *LI,
911911 // TODO: It may be safe to hoist if we are hoisting to a conditional block
912912 // and we have accurately duplicated the control flow from the loop header
913913 // to that block.
914+ // errs() << "Try hoist: "; I.dump();
914915 if (CurLoop->hasLoopInvariantOperands (&I) &&
915916 canSinkOrHoistInst (I, AA, DT, CurLoop, MSSAU, true , Flags, ORE) &&
916917 isSafeToExecuteUnconditionally (
917918 I, DT, TLI, CurLoop, SafetyInfo, ORE,
918919 Preheader->getTerminator (), AC, AllowSpeculation)) {
919920 hoist (I, DT, CurLoop, CFH.getOrCreateHoistedBlock (BB), SafetyInfo,
920921 MSSAU, SE, ORE);
922+ // errs() << "hoisted\n";
921923 HoistedInstructions.push_back (&I);
922924 Changed = true ;
923925 continue ;
@@ -1162,9 +1164,15 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
11621164 bool TargetExecutesOncePerLoop,
11631165 SinkAndHoistLICMFlags &Flags,
11641166 OptimizationRemarkEmitter *ORE) {
1167+
1168+ // errs() << "isHoistableAndSinkableInst\n";
11651169 // If we don't understand the instruction, bail early.
1166- if (!isHoistableAndSinkableInst (I))
1170+ if (!isHoistableAndSinkableInst (I)) {
1171+ // errs() << "No\n";
11671172 return false ;
1173+ }
1174+
1175+ // errs() << "Yes\n";
11681176
11691177 MemorySSA *MSSA = MSSAU.getMemorySSA ();
11701178 // Loads have extra constraints we have to verify before we can hoist them.
@@ -1204,6 +1212,13 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
12041212
12051213 return !Invalidated;
12061214 } else if (CallInst *CI = dyn_cast<CallInst>(&I)) {
1215+ // errs() << "is call\n";
1216+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I)) {
1217+ auto IId = II->getIntrinsicID ();
1218+ if (IId == 3035 )
1219+ return true ;
1220+ // errs() << "Intrinsic with ID: " << IId << "\n";
1221+ }
12071222 // Don't sink or hoist dbg info; it's legal, but not useful.
12081223 if (isa<DbgInfoIntrinsic>(I))
12091224 return false ;
@@ -1790,7 +1805,11 @@ static bool isSafeToExecuteUnconditionally(
17901805
17911806 bool GuaranteedToExecute =
17921807 SafetyInfo->isGuaranteedToExecute (Inst, DT, CurLoop);
1793-
1808+ if (auto II = dyn_cast<IntrinsicInst>(&Inst)) {
1809+ auto IId = II->getIntrinsicID ();
1810+ if (IId == 3035 || IId == 2913 || IId == 2912 )
1811+ return true ;
1812+ }
17941813 if (!GuaranteedToExecute) {
17951814 auto *LI = dyn_cast<LoadInst>(&Inst);
17961815 if (LI && CurLoop->isLoopInvariant (LI->getPointerOperand ()))
0 commit comments