[llvm] [VPlan] Simplify reverse(reverse(x)) -> x (PR #199057)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 08:29:27 PDT 2026


================
@@ -3138,11 +3148,22 @@ void VPlanTransforms::optimizeEVLMasks(VPlan &Plan) {
     }
   }
 
-  // Fold the following splice patterns into vp.reverse for reverse accesses:
+  // Fold the following splice patterns:
+  //   splice.right(splice.left(poison, x, evl), poison, evl) -> x
   //   vector.reverse(splice.left(poison, x, evl))  -> vp.reverse(x, true, evl)
   //   splice.right(vector.reverse(x), poison, evl) -> vp.reverse(x, true, evl)
   for (VPUser *U : collectUsersRecursively(EVL)) {
+    auto *Def = cast<VPRecipeBase>(U);
     VPValue *X;
+    if (match(U, m_Intrinsic<Intrinsic::vector_splice_right>(
----------------
david-arm wrote:

I do agree from a cost model perspective it's much better to remove the splices here because otherwise they are too expensive

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


More information about the llvm-commits mailing list