[llvm] [LV] Don't trigger legacy/vplan assert when forcing costs (PR #156870)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 12 01:52:43 PDT 2025
================
@@ -7047,7 +7047,13 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
// Verify that the VPlan-based and legacy cost models agree, except for VPlans
// with early exits and plans with additional VPlan simplifications. The
// legacy cost model doesn't properly model costs for such loops.
+ // NOTE: If the user has forced a target instruction cost this assert is very
+ // likely to trigger because the VPlan recipes don't map 1:1 with the scalar
+ // instructions that the legacy cost model is based on. One example of this is
+ // for interleave groups - VPlan will use the forced cost for the whole group,
+ // whereas the legacy cost model will use it for each load.
assert((BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() ||
+ ForceTargetInstructionCost.getNumOccurrences() > 0 ||
----------------
fhahn wrote:
Yeah it looks like there are at least a few other isses with forcing target instruction costs, but it seems like some of them seem more like bugs in the VPlan-based cost model. With https://github.com/fhahn/llvm-project/commit/b781919fcf470e50a09dcb2f1710962a07e76c91, I can't see any crashes with `-force-target-instruction-cost=1` on a quite large test set.
Might be worth a try on the test set on your end, if you have a chance
https://github.com/llvm/llvm-project/pull/156870
More information about the llvm-commits
mailing list