Skip to content

Commit 8d037b9

Browse files
authored
[LV][EVL] Skip tryAddExplicitVectorLength for plans with scalar VF. (#125497)
The plans with scalar VF should not be transformed the plans folded by EVL. TODO: Move the scalar VF checking into `LoopVectorizationCostModel ::foldTailWithEVL()`.
1 parent 5367267 commit 8d037b9

File tree

6 files changed

+47
-46
lines changed

6 files changed

+47
-46
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8930,14 +8930,15 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
89308930
for (ElementCount VF = MinVF; ElementCount::isKnownLT(VF, MaxVFTimes2);) {
89318931
VFRange SubRange = {VF, MaxVFTimes2};
89328932
if (auto Plan = tryToBuildVPlanWithVPRecipes(SubRange)) {
8933+
bool HasScalarVF = Plan->hasVF(ElementCount::getFixed(1));
89338934
// Now optimize the initial VPlan.
8934-
if (!Plan->hasVF(ElementCount::getFixed(1)))
8935+
if (!HasScalarVF)
89358936
VPlanTransforms::runPass(VPlanTransforms::truncateToMinimalBitwidths,
89368937
*Plan, CM.getMinimalBitwidths());
89378938
VPlanTransforms::optimize(*Plan);
89388939
// TODO: try to put it close to addActiveLaneMask().
89398940
// Discard the plan if it is not EVL-compatible
8940-
if (CM.foldTailWithEVL() &&
8941+
if (CM.foldTailWithEVL() && !HasScalarVF &&
89418942
!VPlanTransforms::runPass(VPlanTransforms::tryAddExplicitVectorLength,
89428943
*Plan, CM.getMaxSafeElements()))
89438944
break;

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-call-intrinsics.ll

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=IF-EVL %s
77

88
define void @vp_smax(ptr %a, ptr %b, ptr %c, i64 %N) {
9-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
10-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
9+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
10+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
1111
;
1212
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
1313
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -62,8 +62,8 @@ exit:
6262
}
6363

6464
define void @vp_smin(ptr %a, ptr %b, ptr %c, i64 %N) {
65-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
66-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
65+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
66+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
6767
;
6868
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
6969
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -118,8 +118,8 @@ exit:
118118
}
119119

120120
define void @vp_umax(ptr %a, ptr %b, ptr %c, i64 %N) {
121-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
122-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
121+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
122+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
123123
;
124124
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
125125
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -174,8 +174,8 @@ exit:
174174
}
175175

176176
define void @vp_umin(ptr %a, ptr %b, ptr %c, i64 %N) {
177-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
178-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
177+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
178+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
179179
;
180180
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
181181
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -230,8 +230,8 @@ exit:
230230
}
231231

232232
define void @vp_ctlz(ptr %a, ptr %b, i64 %N) {
233-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
234-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
233+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
234+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
235235
;
236236
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
237237
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -281,8 +281,8 @@ exit:
281281
}
282282

283283
define void @vp_cttz(ptr %a, ptr %b, i64 %N) {
284-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
285-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
284+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
285+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
286286
;
287287
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
288288
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -332,8 +332,8 @@ exit:
332332
}
333333

334334
define void @vp_lrint(ptr %a, ptr %b, i64 %N) {
335-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
336-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
335+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
336+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
337337
;
338338
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
339339
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -387,8 +387,8 @@ exit:
387387
}
388388

389389
define void @vp_llrint(ptr %a, ptr %b, i64 %N) {
390-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
391-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
390+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
391+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
392392
;
393393
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
394394
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -442,8 +442,8 @@ exit:
442442
}
443443

444444
define void @vp_abs(ptr %a, ptr %b, i64 %N) {
445-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
446-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
445+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
446+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
447447
;
448448
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
449449
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-cast-intrinsics.ll

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=IF-EVL %s
66

77
define void @vp_sext(ptr %a, ptr %b, i64 %N) {
8-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
9-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
8+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
9+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
1010
;
1111
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2},UF={1}' {
1212
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -58,8 +58,8 @@ exit:
5858
}
5959

6060
define void @vp_zext(ptr %a, ptr %b, i64 %N) {
61-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
62-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
61+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
62+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
6363
;
6464
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2},UF={1}' {
6565
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -109,8 +109,8 @@ exit:
109109
}
110110

111111
define void @vp_trunc(ptr %a, ptr %b, i64 %N) {
112-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
113-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
112+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
113+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
114114
;
115115
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
116116
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -160,8 +160,8 @@ exit:
160160
}
161161

162162
define void @vp_fpext(ptr %a, ptr %b, i64 %N) {
163-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
164-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
163+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
164+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
165165
;
166166
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2},UF={1}' {
167167
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -211,8 +211,8 @@ exit:
211211
}
212212

213213
define void @vp_fptrunc(ptr %a, ptr %b, i64 %N) {
214-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
215-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
214+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
215+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
216216
;
217217
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2},UF={1}' {
218218
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -262,8 +262,8 @@ exit:
262262
}
263263

264264
define void @vp_sitofp(ptr %a, ptr %b, i64 %N) {
265-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
266-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
265+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
266+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
267267
;
268268
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
269269
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -313,8 +313,8 @@ exit:
313313
}
314314

315315
define void @vp_uitofp(ptr %a, ptr %b, i64 %N) {
316-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
317-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
316+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
317+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
318318
;
319319
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
320320
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -364,8 +364,8 @@ exit:
364364
}
365365

366366
define void @vp_fptosi(ptr %a, ptr %b, i64 %N) {
367-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
368-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
367+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
368+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
369369
;
370370
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
371371
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -415,8 +415,8 @@ exit:
415415
}
416416

417417
define void @vp_fptoui(ptr %a, ptr %b, i64 %N) {
418-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
419-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
418+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
419+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
420420
;
421421
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
422422
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
@@ -466,8 +466,8 @@ exit:
466466
}
467467

468468
define void @vp_inttoptr(ptr %a, ptr %b, i64 %N) {
469-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
470-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
469+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
470+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
471471
;
472472
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2},UF={1}' {
473473
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics-reduction.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525

2626
define i32 @reduction(ptr %a, i64 %n, i32 %start) {
27-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
28-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
27+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
28+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
2929

3030
; IF-EVL-OUTLOOP: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
3131
; IF-EVL-OUTLOOP-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefixes=NO-VP,CHECK %s
1212

1313
define void @foo(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
14-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
15-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
14+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
15+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
1616
;
1717
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
1818
; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-select-intrinsics.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=IF-EVL %s
77

88
define void @vp_select(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
9-
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF={1}'
10-
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
9+
; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'
10+
; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
1111
; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}'
1212
; IF-EVL: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI
1313
;

0 commit comments

Comments
 (0)