[llvm] [LV][TTI] Calculate cost of extracting last index in a scalable vector (PR #144086)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 16 07:53:22 PDT 2025


================
@@ -1465,14 +1465,21 @@ class TargetTransformInfo {
       OperandValueInfo Op2Info = {OK_AnyValue, OP_None},
       const Instruction *I = nullptr) const;
 
+  enum : int {
+    UnknownIndex = -1,
+    LastIndex = -2,
----------------
lukel97 wrote:

Should we add a precondition that LastIndex always has to be with a scalable VecTy, similar to VPLane? E.g. it would become `ScalableLastIndex` and `TargetTransformInfo::getVectorInstrCost` and friends would assert the vector is indeed scalable if its used.

That way we wouldn't need to do the `if (isa<ScalableVectorType>(Val))` check + `Index = cast<FixedVectorType>(Val)->getNumElements() - 1;` in each TTI hook

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


More information about the llvm-commits mailing list