[llvm] [X86][LoopVectorize] Enable MaximizeBandwidth by default on X86 with generic split cost floor (PR #201666)
Sumukh J Bharadwaj via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 21:49:07 PDT 2026
================
@@ -320,6 +320,45 @@ InstructionCost VPRecipeBase::cost(ElementCount VF, VPCostContext &Ctx) {
}
}
+ // General split cost floor. When a recipe's result type legalizes into
+ // NumParts > 1 register parts, enforce a cost floor of
+ // NumParts * computeCost(per-part VF). This prevents TTI from
+ // underpricing wide types that exceed register width -- some TTI cost
+ // functions (e.g. for selects, intrinsics) may lack accurate split
+ // models and return optimistic costs for illegal types. The floor
+ // is a no-op when TTI already returns a correctly scaled cost
+ // (e.g. arithmetic, which uses LT.first * OpCost internally).
----------------
amd-subharad wrote:
Thanks for the feedback. We are open to moving this fix into TTI instead. The rationale for placing it here was that it serves as a generic safety net. if TTI underprices any operation on an illegal type due to missing split handling, the floor catches it in one place. That said, we agree with the principle that TTI should be the authority on costs and the vectorizer should trust what TTI returns. Fixing this at the TTI layer would mean addressing the split cost handling across potentially multiple TTI cost API hooks (getCastInstrCost, getCmpSelInstrCost, getIntrinsicInstrCost, etc.) to properly account for asymmetric type legalization which is a broader change
https://github.com/llvm/llvm-project/pull/201666
More information about the llvm-commits
mailing list