[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 05:40:43 PDT 2025


================
@@ -917,6 +918,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
 
     return Res;
   }
+  case VPInstruction::Reverse:
+    return Builder.CreateVectorReverse(State.get(getOperand(0)), "reverse");
----------------
lukel97 wrote:

I'm now thinking, maybe VPInstruction::Reverse should just take a VF operand similar to VPReverseVectorPointerRecipe? If VF != Plan.getVF() then we would emit a vp.reverse intrinsic, otherwise just a regular Builder.CreateVectorReverse.

This way we wouldn't need to manually search for VPinstruction::Reverses and replace them.

I think we should try and explicitly model the things that are needed for correctness, and keep the transforms for things that are just optimising away the header masks.

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


More information about the llvm-commits mailing list