@@ -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,
@@ -7056,22 +7070,6 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
70567070 cast<CmpInst>(UI)->getPredicate ())
70577071 return true ;
70587072
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-
70757073 SeenInstrs.insert (UI);
70767074 }
70777075 }
0 commit comments