@@ -1826,7 +1826,6 @@ class LoopPromoter : public LoadAndStorePromoter {
18261826 ICFLoopSafetyInfo &SafetyInfo;
18271827 bool CanInsertStoresInExitBlocks;
18281828 ArrayRef<const Instruction *> Uses;
1829- bool StoreIsGuanteedToExecute;
18301829
18311830 // We're about to add a use of V in a loop exit block. Insert an LCSSA phi
18321831 // (if legal) if doing so would add an out-of-loop use to an instruction
@@ -1853,15 +1852,13 @@ class LoopPromoter : public LoadAndStorePromoter {
18531852 SmallVectorImpl<MemoryAccess *> &MSSAIP, PredIteratorCache &PIC,
18541853 MemorySSAUpdater &MSSAU, LoopInfo &li, DebugLoc dl,
18551854 Align Alignment, bool UnorderedAtomic, const AAMDNodes &AATags,
1856- ICFLoopSafetyInfo &SafetyInfo, bool CanInsertStoresInExitBlocks,
1857- bool StoreIsGuanteedToExecute)
1855+ ICFLoopSafetyInfo &SafetyInfo, bool CanInsertStoresInExitBlocks)
18581856 : LoadAndStorePromoter(Insts, S), SomePtr(SP), LoopExitBlocks(LEB),
18591857 LoopInsertPts (LIP), MSSAInsertPts(MSSAIP), PredCache(PIC), MSSAU(MSSAU),
18601858 LI(li), DL(std::move(dl)), Alignment(Alignment),
18611859 UnorderedAtomic(UnorderedAtomic), AATags(AATags),
18621860 SafetyInfo(SafetyInfo),
1863- CanInsertStoresInExitBlocks(CanInsertStoresInExitBlocks), Uses(Insts),
1864- StoreIsGuanteedToExecute(StoreIsGuanteedToExecute) {}
1861+ CanInsertStoresInExitBlocks(CanInsertStoresInExitBlocks), Uses(Insts) {}
18651862
18661863 void insertStoresInLoopExitBlocks () {
18671864 // Insert stores after in the loop exit blocks. Each exit block gets a
@@ -1895,7 +1892,7 @@ class LoopPromoter : public LoadAndStorePromoter {
18951892 NewSI->setMetadata (LLVMContext::MD_DIAssignID, NewID);
18961893 }
18971894
1898- if (AATags && StoreIsGuanteedToExecute )
1895+ if (AATags)
18991896 NewSI->setAAMetadata (AATags);
19001897
19011898 MemoryAccess *MSSAInsertPoint = MSSAInsertPts[i];
@@ -2093,8 +2090,10 @@ bool llvm::promoteLoopAccessesToScalars(
20932090 FoundLoadToPromote = true ;
20942091
20952092 Align InstAlignment = Load->getAlign ();
2096- LoadIsGuaranteedToExecute |=
2097- SafetyInfo->isGuaranteedToExecute (*UI, DT, CurLoop);
2093+
2094+ if (!LoadIsGuaranteedToExecute)
2095+ LoadIsGuaranteedToExecute =
2096+ SafetyInfo->isGuaranteedToExecute (*UI, DT, CurLoop);
20982097
20992098 // Note that proving a load safe to speculate requires proving
21002099 // sufficient alignment at the target location. Proving it guaranteed
@@ -2240,8 +2239,9 @@ bool llvm::promoteLoopAccessesToScalars(
22402239 SSAUpdater SSA (&NewPHIs);
22412240 LoopPromoter Promoter (SomePtr, LoopUses, SSA, ExitBlocks, InsertPts,
22422241 MSSAInsertPts, PIC, MSSAU, *LI, DL, Alignment,
2243- SawUnorderedAtomic, AATags, *SafetyInfo,
2244- StoreSafety == StoreSafe, StoreIsGuanteedToExecute);
2242+ SawUnorderedAtomic,
2243+ StoreIsGuanteedToExecute ? AATags : AAMDNodes (),
2244+ *SafetyInfo, StoreSafety == StoreSafe);
22452245
22462246 // Set up the preheader to have a definition of the value. It is the live-out
22472247 // value from the preheader that uses in the loop will use.
0 commit comments