[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)
    Shih-Po Hung via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Aug  7 17:07:06 PDT 2025
    
    
  
================
@@ -917,6 +918,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
 
     return Res;
   }
+  case VPInstruction::Reverse:
+    return Builder.CreateVectorReverse(State.get(getOperand(0)), "reverse");
----------------
arcbbb wrote:
Although I prefer using VF explicitly, I don't see a correctness issue with the first approach in the current state.
First approach: Reverse does not carry a VF operand.
  1. EVL tailfolding must replace the Reverse recipe with a widen intrinsic recipe, since no VF is available.
 
Second approach: Reverse carries a VF operand.
1. EVL tailfolding can either replace VF with EVL (ensuring  vp.reverse is generated) , or replace the Reverse recipe with a widen intrinsic recipe as in the first approach.
The two approaches seem similar to me.
Even though the function is named `optimizeMaskToEVL`, EVL transform for both WidenLoadRecipe and ReverseRecipe seems necessary for correctness.
https://github.com/llvm/llvm-project/pull/146525
    
    
More information about the llvm-commits
mailing list