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

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 02:56:09 PDT 2025


================
@@ -1512,6 +1512,14 @@ class TargetTransformInfo {
                                               TTI::TargetCostKind CostKind,
                                               unsigned Index = -1) const;
 
+  /// \return The expected cost of inserting or extracting a lane that is \p
+  /// Index from the end of a vector, i.e. the mathematical expression for
+  /// the lane is (VF - 1 - Index). This is required for scalable vectors where
+  /// the exact lane index is unknown at compile time.
+  LLVM_ABI InstructionCost
+  getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
----------------
paulwalker-arm wrote:

Adding "indexed" (i.e. getIndexedVectorInstrCostFromEnd) would add context to the function and make it clearer what "FromEnd" means.

In the same way, the original function could use an "indexed" variant (i.e. getIndexedVectorInstrCost) to improve clarity but that's nothing to do with this PR.

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


More information about the llvm-commits mailing list