Skip to content

Commit 69053f5

Browse files
committed
Change planContainsAdditionalSimplifications for licm
1 parent 61f053d commit 69053f5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6939,6 +6939,23 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
69396939
cast<VPRecipeWithIRFlags>(R).getPredicate() !=
69406940
cast<CmpInst>(UI)->getPredicate())
69416941
return true;
6942+
6943+
if (auto *MemR = dyn_cast<VPWidenMemoryRecipe>(&R)) {
6944+
if (MemR->isReverse()) {
6945+
// If the stored value of a reverse store is invariant, LICM will
6946+
// hoist the reverse operation to the preheader. In this case, the
6947+
// result of the VPlan-based cost model will diverge from that of
6948+
// the legacy model.
6949+
if (auto *StoreR = dyn_cast<VPWidenStoreRecipe>(MemR))
6950+
if (StoreR->getStoredValue()->isDefinedOutsideLoopRegions())
6951+
return true;
6952+
6953+
if (auto *StoreR = dyn_cast<VPWidenStoreEVLRecipe>(MemR))
6954+
if (StoreR->getStoredValue()->isDefinedOutsideLoopRegions())
6955+
return true;
6956+
}
6957+
}
6958+
69426959
SeenInstrs.insert(UI);
69436960
}
69446961
}

0 commit comments

Comments
 (0)