Skip to content

Commit 3dbf0b1

Browse files
fhahnAlexisPerry
authored andcommitted
[VPlan] Don't compute costs if there are no vector VPlans.
In some cases, no vector VPlans can be constructed due to failing VPlan legality checks (e.g. unable to perform sinking for first order recurrences or plans being incompatible with EVL). There's no need to compute costs in those cases, so check directly if there are no vector plans.
1 parent 662400e commit 3dbf0b1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7294,7 +7294,8 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
72947294
buildVPlansWithVPRecipes(ElementCount::getScalable(1), MaxFactors.ScalableVF);
72957295

72967296
LLVM_DEBUG(printPlans(dbgs()));
7297-
if (!MaxFactors.hasVector())
7297+
if (all_of(VPlans,
7298+
[](std::unique_ptr<VPlan> &P) { return P->hasScalarVFOnly(); }))
72987299
return VectorizationFactor::Disabled();
72997300

73007301
// Select the optimal vectorization factor.

llvm/test/Transforms/LoopVectorize/RISCV/only-compute-cost-for-vplan-vfs.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
; REQUIRES: asserts
66

77
; Make sure we do not vectorize a loop with a widened int induction.
8-
; TODO: There's no need to compute costs for any VF, as no VPlans have been generated.
98
define void @test_wide_integer_induction(ptr noalias %a, i64 %N) {
10-
; CHECK: LV: Vector loop of width {{.+}} costs:
9+
; CHECK-NOT: LV: Vector loop of width {{.+}} costs:
1110
;
1211
; CHECK: define void @test_wide_integer_induction(
1312
; CHECK-NOT: vector.body

0 commit comments

Comments
 (0)