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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 06:24:30 PDT 2025


================
@@ -1147,6 +1150,13 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
                                   I32Ty, {Arg0Ty, I32Ty, I1Ty});
     return Ctx.TTI.getIntrinsicInstrCost(Attrs, Ctx.CostKind);
   }
+  case VPInstruction::Reverse: {
+    assert(VF.isVector() && "Reverse operation must be vector type");
+    Type *VectorTy = toVectorTy(Ctx.Types.inferScalarType(getOperand(0)), VF);
+    return Ctx.TTI.getShuffleCost(
+        TargetTransformInfo::SK_Reverse, cast<VectorType>(VectorTy),
+        cast<VectorType>(VectorTy), {}, Ctx.CostKind, 0);
----------------
fhahn wrote:

```suggestion
    Type *VectorTy =  cast<VectorType>(toVectorTy(Ctx.Types.inferScalarType(getOperand(0)), VF));
    return Ctx.TTI.getShuffleCost(
        TargetTransformInfo::SK_Reverse, VectorTy,
       VectorTy, {}, Ctx.CostKind, 0);
```

Could you also add `/*Arg=*/ to the arguments passing {} and 0?

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


More information about the llvm-commits mailing list