@@ -1826,6 +1826,7 @@ class LoopPromoter : public LoadAndStorePromoter {
1826
1826
ICFLoopSafetyInfo &SafetyInfo;
1827
1827
bool CanInsertStoresInExitBlocks;
1828
1828
ArrayRef<const Instruction *> Uses;
1829
+ bool StoreIsGuanteedToExecute;
1829
1830
1830
1831
// We're about to add a use of V in a loop exit block. Insert an LCSSA phi
1831
1832
// (if legal) if doing so would add an out-of-loop use to an instruction
@@ -1852,13 +1853,15 @@ class LoopPromoter : public LoadAndStorePromoter {
1852
1853
SmallVectorImpl<MemoryAccess *> &MSSAIP, PredIteratorCache &PIC,
1853
1854
MemorySSAUpdater &MSSAU, LoopInfo &li, DebugLoc dl,
1854
1855
Align Alignment, bool UnorderedAtomic, const AAMDNodes &AATags,
1855
- ICFLoopSafetyInfo &SafetyInfo, bool CanInsertStoresInExitBlocks)
1856
+ ICFLoopSafetyInfo &SafetyInfo, bool CanInsertStoresInExitBlocks,
1857
+ bool StoreIsGuanteedToExecute)
1856
1858
: LoadAndStorePromoter(Insts, S), SomePtr(SP), LoopExitBlocks(LEB),
1857
1859
LoopInsertPts (LIP), MSSAInsertPts(MSSAIP), PredCache(PIC), MSSAU(MSSAU),
1858
1860
LI(li), DL(std::move(dl)), Alignment(Alignment),
1859
1861
UnorderedAtomic(UnorderedAtomic), AATags(AATags),
1860
1862
SafetyInfo(SafetyInfo),
1861
- CanInsertStoresInExitBlocks(CanInsertStoresInExitBlocks), Uses(Insts) {}
1863
+ CanInsertStoresInExitBlocks(CanInsertStoresInExitBlocks), Uses(Insts),
1864
+ StoreIsGuanteedToExecute(StoreIsGuanteedToExecute) {}
1862
1865
1863
1866
void insertStoresInLoopExitBlocks () {
1864
1867
// Insert stores after in the loop exit blocks. Each exit block gets a
@@ -1892,7 +1895,7 @@ class LoopPromoter : public LoadAndStorePromoter {
1892
1895
NewSI->setMetadata (LLVMContext::MD_DIAssignID, NewID);
1893
1896
}
1894
1897
1895
- if (AATags)
1898
+ if (AATags && StoreIsGuanteedToExecute )
1896
1899
NewSI->setAAMetadata (AATags);
1897
1900
1898
1901
MemoryAccess *MSSAInsertPoint = MSSAInsertPts[i];
@@ -2090,7 +2093,8 @@ bool llvm::promoteLoopAccessesToScalars(
2090
2093
FoundLoadToPromote = true ;
2091
2094
2092
2095
Align InstAlignment = Load->getAlign ();
2093
- LoadIsGuaranteedToExecut |= SafetyInfo->isGuaranteedToExecute (*UI, DT, CurLoop);
2096
+ LoadIsGuaranteedToExecute |=
2097
+ SafetyInfo->isGuaranteedToExecute (*UI, DT, CurLoop);
2094
2098
2095
2099
// Note that proving a load safe to speculate requires proving
2096
2100
// sufficient alignment at the target location. Proving it guaranteed
@@ -2237,7 +2241,7 @@ bool llvm::promoteLoopAccessesToScalars(
2237
2241
LoopPromoter Promoter (SomePtr, LoopUses, SSA, ExitBlocks, InsertPts,
2238
2242
MSSAInsertPts, PIC, MSSAU, *LI, DL, Alignment,
2239
2243
SawUnorderedAtomic, AATags, *SafetyInfo,
2240
- StoreSafety == StoreSafe);
2244
+ StoreSafety == StoreSafe, StoreIsGuanteedToExecute );
2241
2245
2242
2246
// Set up the preheader to have a definition of the value. It is the live-out
2243
2247
// value from the preheader that uses in the loop will use.
0 commit comments