[llvm] [VPlan] Simplify reverse(reverse(x)) -> x (PR #199057)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 02:35:14 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>(
----------------
Mel-Chen wrote:
I think splice elimination is worth spinning off into a separate patch, provided there are no performance regressions.
Interestingly, I noticed that the cost of RISCV `vp.reverse` is actually higher than `vector.splice`. I'm not sure if there's an issue with the cost model here, but even if we only eliminate `vector.reverse` and leave `vector.splice`, the overall VPlan-based cost for EVL tail folding still decreases.
Could we check how bad the generated assembly looks with the leftover splice to help us decide whether to handle its elimination separately?
https://github.com/llvm/llvm-project/pull/199057
More information about the llvm-commits
mailing list