Skip to content

Commit f4ad136

Browse files
committed
[LV] Add option -bypass-vf-comparison to bypass VF comparison. NFC
The assertion of checking if the VF selected by legacy model and the vplan-based cost model is good for user to find if the vplan-based cost model is misaligned to the legacy cost model. But the assertion may block users from compiling their program normally. Adding this option lets users report the issue and compile their program normally.
1 parent af47038 commit f4ad136

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ static cl::opt<bool> UseWiderVFIfCallVariantsPresent(
384384
cl::Hidden,
385385
cl::desc("Try wider VFs if they enable the use of vector variants"));
386386

387+
// Bypass the assertion when the VF selected by vplan-based cost model is
388+
// different from the VF selected by legacy cost model.
389+
static cl::opt<bool>
390+
BypassVFComparison("bypass-vf-comparison", cl::init(false), cl::Hidden,
391+
cl::desc("Bypass VF comparison between legacy cost "
392+
"model and the vplan-base cost model."));
393+
387394
// Likelyhood of bypassing the vectorized loop because assumptions about SCEV
388395
// variables not overflowing do not hold. See `emitSCEVChecks`.
389396
static constexpr uint32_t SCEVCheckBypassWeights[] = {1, 127};
@@ -7383,10 +7390,13 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
73837390
// different VF to be picked by the VPlan-based cost model.
73847391
VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(), CM);
73857392
precomputeCosts(BestPlan, BestFactor.Width, CostCtx);
7386-
assert((BestFactor.Width == LegacyVF.Width ||
7393+
assert(BypassVFComparison ||
7394+
(BestFactor.Width == LegacyVF.Width ||
73877395
planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),
73887396
CostCtx, OrigLoop)) &&
7389-
" VPlan cost model and legacy cost model disagreed");
7397+
" VPlan cost model and legacy cost model disagreed. Please report "
7398+
"the issue and you can bypass "
7399+
"this assertion by `-bypass-vf-comparison=true`.");
73907400
assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) &&
73917401
"when vectorizing, the scalar cost must be computed.");
73927402
#endif

0 commit comments

Comments
 (0)