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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 16 23:35:03 PDT 2025


================
@@ -1486,7 +1493,7 @@ class TargetTransformInfo {
   /// of the extract(nullptr if user is not known before vectorization) and
   /// 'Idx' being the extract lane.
   LLVM_ABI InstructionCost getVectorInstrCost(
-      unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
+      unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, int Index,
----------------
david-arm wrote:

I have done that implicitly by changing all the TTI hooks to call `isKnownVectorIndex` when testing if the index is known or not. Any code that previously compared against -1 now calls `isKnownVectorIndex`, which returns false whether the index is -1 or -2 so as far as I can tell the change is NFC for all other targets.

There may be places where target hooks were never checking for -1 and always assuming a known index - I figured in those cases my patch doesn't make things any more broken than they were already.

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


More information about the llvm-commits mailing list