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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 08:28:46 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:

OK thanks for the explanation. In that case, is it worth separately also adding such a transform to InstCombine since the LangRef guarantees the safety of it? Or is the loop vectoriser the only possible source of such IR and therefore adds no value?

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


More information about the llvm-commits mailing list