[llvm] [LoopVectorize] Use CodeSize as the cost kind for minsize (PR #124119)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 06:44:39 PST 2025


================
@@ -793,7 +793,7 @@ InstructionCost VPRegionBlock::cost(ElementCount VF, VPCostContext &Ctx) {
 
   // For the scalar case, we may not always execute the original predicated
   // block, Thus, scale the block's cost by the probability of executing it.
-  if (VF.isScalar())
+  if (VF.isScalar() && Ctx.CostKind != TTI::TCK_CodeSize)
     return ThenCost / getReciprocalPredBlockProb();
----------------
fhahn wrote:

Might be better to update `getReciprocalPredBlockProb` to take cost kind instead and return `1` for CodeSize? That would make sure all places that call it are updated and make it more likely to correctly handle TCK_CodeSize in new uses in the future?

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


More information about the llvm-commits mailing list