Skip to content

Commit 0d4aa7d

Browse files
committed
Move the code in planContainsAdditionalSimplifications
1 parent 7ed94d7 commit 0d4aa7d

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7035,6 +7035,20 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
70357035
if (AddrI && vputils::isSingleScalar(WidenMemR->getAddr()) !=
70367036
CostCtx.isLegacyUniformAfterVectorization(AddrI, VF))
70377037
return true;
7038+
7039+
if (WidenMemR->isReverse()) {
7040+
// If the stored value of a reverse store is invariant, LICM will
7041+
// hoist the reverse operation to the preheader. In this case, the
7042+
// result of the VPlan-based cost model will diverge from that of
7043+
// the legacy model.
7044+
if (auto *StoreR = dyn_cast<VPWidenStoreRecipe>(WidenMemR))
7045+
if (StoreR->getStoredValue()->isDefinedOutsideLoopRegions())
7046+
return true;
7047+
7048+
if (auto *StoreR = dyn_cast<VPWidenStoreEVLRecipe>(WidenMemR))
7049+
if (StoreR->getStoredValue()->isDefinedOutsideLoopRegions())
7050+
return true;
7051+
}
70387052
}
70397053

70407054
/// If a VPlan transform folded a recipe to one producing a single-scalar,
@@ -7055,23 +7069,6 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
70557069
cast<VPRecipeWithIRFlags>(R).getPredicate() !=
70567070
cast<CmpInst>(UI)->getPredicate())
70577071
return true;
7058-
7059-
if (auto *MemR = dyn_cast<VPWidenMemoryRecipe>(&R)) {
7060-
if (MemR->isReverse()) {
7061-
// If the stored value of a reverse store is invariant, LICM will
7062-
// hoist the reverse operation to the preheader. In this case, the
7063-
// result of the VPlan-based cost model will diverge from that of
7064-
// the legacy model.
7065-
if (auto *StoreR = dyn_cast<VPWidenStoreRecipe>(MemR))
7066-
if (StoreR->getStoredValue()->isDefinedOutsideLoopRegions())
7067-
return true;
7068-
7069-
if (auto *StoreR = dyn_cast<VPWidenStoreEVLRecipe>(MemR))
7070-
if (StoreR->getStoredValue()->isDefinedOutsideLoopRegions())
7071-
return true;
7072-
}
7073-
}
7074-
70757072
SeenInstrs.insert(UI);
70767073
}
70777074
}

0 commit comments

Comments
 (0)