You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[RISCV][VLOPT] Allow propagation even when VL isn't VLMAX (#112228)
The original goal of this pass was to focus on vector operations with
VLMAX. However, users often utilize only part of the result, and such
usage may come from the vectorizer.
We found that relaxing this constraint can capture more optimization
opportunities, such as non-power-of-2 code generation and vector
operation sequences with different VLs.
---------
Co-authored-by: Kito Cheng <[email protected]>
Copy file name to clipboardExpand all lines: llvm/test/CodeGen/RISCV/rvv/vl-opt.ll
+36-14Lines changed: 36 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -11,19 +11,46 @@
11
11
declare <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, iXLen)
12
12
13
13
define <vscale x 4 x i32> @different_imm_vl_with_ta(<vscale x 4 x i32> %passthru, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
14
-
; CHECK-LABEL: different_imm_vl_with_ta:
15
-
; CHECK: # %bb.0:
16
-
; CHECK-NEXT: vsetivli zero, 5, e32, m2, ta, ma
17
-
; CHECK-NEXT: vadd.vv v8, v10, v12
18
-
; CHECK-NEXT: vsetivli zero, 4, e32, m2, ta, ma
19
-
; CHECK-NEXT: vadd.vv v8, v8, v10
20
-
; CHECK-NEXT: ret
14
+
; NOVLOPT-LABEL: different_imm_vl_with_ta:
15
+
; NOVLOPT: # %bb.0:
16
+
; NOVLOPT-NEXT: vsetivli zero, 5, e32, m2, ta, ma
17
+
; NOVLOPT-NEXT: vadd.vv v8, v10, v12
18
+
; NOVLOPT-NEXT: vsetivli zero, 4, e32, m2, ta, ma
19
+
; NOVLOPT-NEXT: vadd.vv v8, v8, v10
20
+
; NOVLOPT-NEXT: ret
21
+
;
22
+
; VLOPT-LABEL: different_imm_vl_with_ta:
23
+
; VLOPT: # %bb.0:
24
+
; VLOPT-NEXT: vsetivli zero, 4, e32, m2, ta, ma
25
+
; VLOPT-NEXT: vadd.vv v8, v10, v12
26
+
; VLOPT-NEXT: vadd.vv v8, v8, v10
27
+
; VLOPT-NEXT: ret
21
28
%v = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen 5)
22
29
%w = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %v, <vscale x 4 x i32> %a, iXLen 4)
23
30
ret <vscale x 4 x i32> %w
24
31
}
25
32
26
-
; No benificial to propagate VL since VL is larger in the use side.
33
+
define <vscale x 4 x i32> @vlmax_and_imm_vl_with_ta(<vscale x 4 x i32> %passthru, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
34
+
; NOVLOPT-LABEL: vlmax_and_imm_vl_with_ta:
35
+
; NOVLOPT: # %bb.0:
36
+
; NOVLOPT-NEXT: vsetvli a0, zero, e32, m2, ta, ma
37
+
; NOVLOPT-NEXT: vadd.vv v8, v10, v12
38
+
; NOVLOPT-NEXT: vsetivli zero, 4, e32, m2, ta, ma
39
+
; NOVLOPT-NEXT: vadd.vv v8, v8, v10
40
+
; NOVLOPT-NEXT: ret
41
+
;
42
+
; VLOPT-LABEL: vlmax_and_imm_vl_with_ta:
43
+
; VLOPT: # %bb.0:
44
+
; VLOPT-NEXT: vsetivli zero, 4, e32, m2, ta, ma
45
+
; VLOPT-NEXT: vadd.vv v8, v10, v12
46
+
; VLOPT-NEXT: vadd.vv v8, v8, v10
47
+
; VLOPT-NEXT: ret
48
+
%v = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen -1)
49
+
%w = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %v, <vscale x 4 x i32> %a, iXLen 4)
50
+
ret <vscale x 4 x i32> %w
51
+
}
52
+
53
+
; Not beneficial to propagate VL since VL is larger in the use side.
27
54
define <vscale x 4 x i32> @different_imm_vl_with_ta_larger_vl(<vscale x 4 x i32> %passthru, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
@@ -50,8 +77,7 @@ define <vscale x 4 x i32> @different_imm_reg_vl_with_ta(<vscale x 4 x i32> %pass
50
77
ret <vscale x 4 x i32> %w
51
78
}
52
79
53
-
54
-
; No benificial to propagate VL since VL is already one.
80
+
; Not beneficial to propagate VL since VL is already one.
55
81
define <vscale x 4 x i32> @different_imm_vl_with_ta_1(<vscale x 4 x i32> %passthru, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
56
82
; CHECK-LABEL: different_imm_vl_with_ta_1:
57
83
; CHECK: # %bb.0:
@@ -110,7 +136,3 @@ define <vscale x 4 x i32> @different_imm_vl_with_tu(<vscale x 4 x i32> %passthru
110
136
%w = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> %passthru, <vscale x 4 x i32> %v, <vscale x 4 x i32> %a,iXLen 4)
111
137
ret <vscale x 4 x i32> %w
112
138
}
113
-
114
-
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
0 commit comments