@@ -1826,6 +1826,7 @@ class LoopPromoter : public LoadAndStorePromoter {
18261826 ICFLoopSafetyInfo &SafetyInfo;
18271827 bool CanInsertStoresInExitBlocks;
18281828 ArrayRef<const Instruction *> Uses;
1829+ bool StoreIsGuanteedToExecute;
18291830
18301831 // We're about to add a use of V in a loop exit block. Insert an LCSSA phi
18311832 // (if legal) if doing so would add an out-of-loop use to an instruction
@@ -1852,13 +1853,15 @@ class LoopPromoter : public LoadAndStorePromoter {
18521853 SmallVectorImpl<MemoryAccess *> &MSSAIP, PredIteratorCache &PIC,
18531854 MemorySSAUpdater &MSSAU, LoopInfo &li, DebugLoc dl,
18541855 Align Alignment, bool UnorderedAtomic, const AAMDNodes &AATags,
1855- ICFLoopSafetyInfo &SafetyInfo, bool CanInsertStoresInExitBlocks)
1856+ ICFLoopSafetyInfo &SafetyInfo, bool CanInsertStoresInExitBlocks,
1857+ bool StoreIsGuanteedToExecute)
18561858 : LoadAndStorePromoter(Insts, S), SomePtr(SP), LoopExitBlocks(LEB),
18571859 LoopInsertPts (LIP), MSSAInsertPts(MSSAIP), PredCache(PIC), MSSAU(MSSAU),
18581860 LI(li), DL(std::move(dl)), Alignment(Alignment),
18591861 UnorderedAtomic(UnorderedAtomic), AATags(AATags),
18601862 SafetyInfo(SafetyInfo),
1861- CanInsertStoresInExitBlocks(CanInsertStoresInExitBlocks), Uses(Insts) {}
1863+ CanInsertStoresInExitBlocks(CanInsertStoresInExitBlocks), Uses(Insts),
1864+ StoreIsGuanteedToExecute(StoreIsGuanteedToExecute) {}
18621865
18631866 void insertStoresInLoopExitBlocks () {
18641867 // Insert stores after in the loop exit blocks. Each exit block gets a
@@ -1892,7 +1895,7 @@ class LoopPromoter : public LoadAndStorePromoter {
18921895 NewSI->setMetadata (LLVMContext::MD_DIAssignID, NewID);
18931896 }
18941897
1895- if (AATags)
1898+ if (AATags && StoreIsGuanteedToExecute )
18961899 NewSI->setAAMetadata (AATags);
18971900
18981901 MemoryAccess *MSSAInsertPoint = MSSAInsertPts[i];
@@ -2090,7 +2093,8 @@ bool llvm::promoteLoopAccessesToScalars(
20902093 FoundLoadToPromote = true ;
20912094
20922095 Align InstAlignment = Load->getAlign ();
2093- LoadIsGuaranteedToExecut |= SafetyInfo->isGuaranteedToExecute (*UI, DT, CurLoop);
2096+ LoadIsGuaranteedToExecute |=
2097+ SafetyInfo->isGuaranteedToExecute (*UI, DT, CurLoop);
20942098
20952099 // Note that proving a load safe to speculate requires proving
20962100 // sufficient alignment at the target location. Proving it guaranteed
@@ -2237,7 +2241,7 @@ bool llvm::promoteLoopAccessesToScalars(
22372241 LoopPromoter Promoter (SomePtr, LoopUses, SSA, ExitBlocks, InsertPts,
22382242 MSSAInsertPts, PIC, MSSAU, *LI, DL, Alignment,
22392243 SawUnorderedAtomic, AATags, *SafetyInfo,
2240- StoreSafety == StoreSafe);
2244+ StoreSafety == StoreSafe, StoreIsGuanteedToExecute );
22412245
22422246 // Set up the preheader to have a definition of the value. It is the live-out
22432247 // value from the preheader that uses in the loop will use.
0 commit comments