[llvm] [LV] Use getFixedValue instead of getKnownMinValue when appropriate (PR #143526)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 07:17:50 PDT 2025


================
@@ -5342,6 +5342,10 @@ LoopVectorizationCostModel::getUniformMemOpCost(Instruction *I,
   StoreInst *SI = cast<StoreInst>(I);
 
   bool IsLoopInvariantStoreValue = Legal->isInvariant(SI->getValueOperand());
+  // TODO: We have tests that request the cost of extracting element
+  // VF.getKnownMinValue() - 1 from a scalable vector. This is actually
+  // meaningless, given what we actually want is the last lane and is likely
+  // to be more expensive.
----------------
fhahn wrote:

The issue is generally that we allow to invariant addresses with scalable vectors and for those we may have to extract the last lane, but we query the last *known* lane, which is not what we need for scalable vectors, right?

Might be good to adjust the comment a bit, we have tests to exercise this code, but might be clearer to just explain the problematic code path?

Also, I presume that there's no way to query TTI for the last lane of a scalable vector at the moment?

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


More information about the llvm-commits mailing list