[llvm] [VPlan] Extract reverse mask from reverse accesses (PR #155579)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 29 09:35:18 PDT 2026


================
@@ -3799,9 +3815,29 @@ InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
     // TODO: Using the original IR may not be accurate.
     // Currently, ARM will use the underlying IR to calculate gather/scatter
     // instruction cost.
-    assert(!Reverse &&
-           "Inconsecutive memory access should not have the order.");
+#ifndef NDEBUG
+    auto IsReverse = [this]() {
+      // Check if mask is reversed
+      if (VPValue *Mask = getMask())
+        if (match(Mask, m_Reverse(m_VPValue())))
+          return true;
+
+      // For loads, check if the single user is a reverse operation
+      if (isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(this)) {
+        auto *U = getVPSingleValue()->getSingleUser();
+        return U && match(cast<VPRecipeBase>(U), m_Reverse(m_VPValue()));
+      }
 
+      // For stores, check if the stored value is reversed
----------------
fhahn wrote:

```suggestion
      // For stores, check if the stored value is reversed.
```

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


More information about the llvm-commits mailing list