[llvm] [LV] Remove selectUserVF, remove use of legacy expectedCost (NFCI) (PR #191216)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 02:07:26 PDT 2026
================
@@ -5014,43 +4999,22 @@ InstructionCost LoopVectorizationCostModel::expectedCost(ElementCount VF) {
// For each instruction in the old loop.
for (Instruction &I : *BB) {
// Skip ignored values.
- if (ValuesToIgnore.count(&I) || ValuesToIgnoreForVF.count(&I) ||
+ if (ValuesToIgnore.count(&I) ||
(VF.isVector() && VecValuesToIgnore.count(&I)))
continue;
InstructionCost C = getInstructionCost(&I, VF);
// Check if we should override the cost.
- if (C.isValid() && ForceTargetInstructionCost.getNumOccurrences() > 0) {
- // For interleave groups, use ForceTargetInstructionCost once for the
- // whole group.
- if (VF.isVector() && getWideningDecision(&I, VF) == CM_Interleave) {
- if (getInterleavedAccessGroup(&I)->getInsertPos() == &I)
- C = InstructionCost(ForceTargetInstructionCost);
- else
- C = InstructionCost(0);
- } else {
- C = InstructionCost(ForceTargetInstructionCost);
- }
- }
+ if (C.isValid() && ForceTargetInstructionCost.getNumOccurrences() > 0)
+ C = InstructionCost(ForceTargetInstructionCost);
BlockCost += C;
LLVM_DEBUG(dbgs() << "LV: Found an estimated cost of " << C << " for VF "
<< VF << " For instruction: " << I << '\n');
}
- // If we are vectorizing a predicated block, it will have been
- // if-converted. This means that the block's instructions (aside from
- // stores and instructions that may divide by zero) will now be
- // unconditionally executed. For the scalar case, we may not always execute
- // the predicated block, if it is an if-else block. Thus, scale the block's
- // cost by the probability of executing it.
- // getPredBlockCostDivisor will return 1 for blocks that are only predicated
- // by the header mask when folding the tail.
- if (VF.isScalar())
- BlockCost /= getPredBlockCostDivisor(CostKind, BB);
-
- Cost += BlockCost;
+ Cost += BlockCost / getPredBlockCostDivisor(CostKind, BB);
----------------
fhahn wrote:
Thanks, I added back a slightly re-worded version regarding the scalar loop
https://github.com/llvm/llvm-project/pull/191216
More information about the llvm-commits
mailing list