[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 06:24:30 PDT 2025


================
@@ -2482,6 +2482,29 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
       .Case<VPWidenStoreRecipe>([&](VPWidenStoreRecipe *S) {
         VPValue *NewMask = GetNewMask(S->getMask());
         VPValue *NewAddr = GetNewAddr(S->getAddr());
+        // Convert general reverse operations on stored value into vp.reverse,
+        // when the VPVectorEndPointerRecipe adjusting the access address uses
+        // EVL instead of VF.
+        if (match(NewAddr, m_VectorEndPointer(m_VPValue(), m_Specific(&EVL)))) {
+          VPValue *StoredVal = S->getStoredValue();
+          // Skip if the stored value is not defined in the loop region.
+          if (!StoredVal->isDefinedOutsideLoopRegions()) {
----------------
fhahn wrote:

Hmm, is this correct even if the value outside the region is a vector other than a broadcast?

https://github.com/llvm/llvm-project/pull/146525


More information about the llvm-commits mailing list