[llvm] [VPlan][NFC] Simplify reverse access pattern detection in EVL vectorization (PR #199510)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 06:43:19 PDT 2026


================
@@ -1639,6 +1639,26 @@ static void simplifyRecipe(VPSingleDefRecipe *Def, VPTypeAnalysis &TypeInfo) {
     return;
   }
 
+  if (match(Def, m_Reverse(m_Intrinsic<Intrinsic::vector_splice_left>(
+                     m_Poison(), m_VPValue(X), m_VPValue(Y)))) &&
+      match(Y, m_EVL(m_VPValue()))) {
+    auto *VPReverse = new VPWidenIntrinsicRecipe(
+        Intrinsic::experimental_vp_reverse, {X, Plan->getTrue(), Y},
+        TypeInfo.inferScalarType(X), {}, {}, Def->getDebugLoc());
+    VPReverse->insertBefore(Def);
+    return Def->replaceAllUsesWith(VPReverse);
+  }
+
+  if (match(Def, m_Intrinsic<Intrinsic::vector_splice_right>(
+                      m_Reverse(m_VPValue(X)), m_Poison(), m_VPValue(Y))) &&
+      match(Y, m_EVL(m_VPValue()))) {
+    auto *VPReverse = new VPWidenIntrinsicRecipe(
+        Intrinsic::experimental_vp_reverse, {X, Plan->getTrue(), Y},
+        TypeInfo.inferScalarType(X), {}, {}, Def->getDebugLoc());
+    VPReverse->insertBefore(Def);
+    return Def->replaceAllUsesWith(VPReverse);
+  }
----------------
Mel-Chen wrote:

It just occurred to me, after we remove the vp.reverse intrinsic, do we need to introduce a new kind of VPExpressionRecipe to maintain cost model consistency?

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


More information about the llvm-commits mailing list