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
We currently check for passthrus in two places, on the instruction to
reduce in isCandidate, and on the users in checkUsers.
We cannot reduce the VL if an instruction has a user that's a passthru,
because the user will read elements past VL in the tail.
However it's fine to reduce an instruction if it itself contains a
non-undef passthru. Since the VL can only be reduced, not increased, the
previous tail will always remain the same.
Copy file name to clipboardExpand all lines: llvm/test/CodeGen/RISCV/rvv/vl-opt.ll
+52-8Lines changed: 52 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,8 @@ define <vscale x 4 x i32> @different_vl_with_ta(<vscale x 4 x i32> %a, <vscale x
107
107
ret <vscale x 4 x i32> %w
108
108
}
109
109
110
-
; Test case to make sure VL won't propgate if using tail-undisturbed policy.
110
+
; We can propagate VL to a tail-undisturbed policy, provided none of its users
111
+
; are passthrus (i.e. read past VL).
111
112
define <vscale x 4 x i32> @different_vl_with_tu(<vscale x 4 x i32> %passthru, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
112
113
; CHECK-LABEL: different_vl_with_tu:
113
114
; CHECK: # %bb.0:
@@ -118,22 +119,65 @@ define <vscale x 4 x i32> @different_vl_with_tu(<vscale x 4 x i32> %passthru, <v
118
119
; CHECK-NEXT: vadd.vv v8, v14, v10
119
120
; CHECK-NEXT: ret
120
121
%v = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1)
121
-
%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 %vl2)
122
+
%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 %vl2)
122
123
ret <vscale x 4 x i32> %w
123
124
}
124
125
125
-
; Test case to make sure VL won't propgate if using tail-undisturbed policy.
126
+
; We can propagate VL to a tail-undisturbed policy, provided none of its users
127
+
; are passthrus (i.e. read past VL).
126
128
define <vscale x 4 x i32> @different_imm_vl_with_tu(<vscale x 4 x i32> %passthru, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
127
-
; CHECK-LABEL: different_imm_vl_with_tu:
129
+
; NOVLOPT-LABEL: different_imm_vl_with_tu:
130
+
; NOVLOPT: # %bb.0:
131
+
; NOVLOPT-NEXT: vsetivli zero, 5, e32, m2, tu, ma
132
+
; NOVLOPT-NEXT: vmv2r.v v14, v10
133
+
; NOVLOPT-NEXT: vadd.vv v14, v10, v12
134
+
; NOVLOPT-NEXT: vsetivli zero, 4, e32, m2, tu, ma
135
+
; NOVLOPT-NEXT: vadd.vv v8, v14, v10
136
+
; NOVLOPT-NEXT: ret
137
+
;
138
+
; VLOPT-LABEL: different_imm_vl_with_tu:
139
+
; VLOPT: # %bb.0:
140
+
; VLOPT-NEXT: vsetivli zero, 4, e32, m2, tu, ma
141
+
; VLOPT-NEXT: vmv2r.v v14, v10
142
+
; VLOPT-NEXT: vadd.vv v14, v10, v12
143
+
; VLOPT-NEXT: vadd.vv v8, v14, v10
144
+
; VLOPT-NEXT: ret
145
+
%v = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen 5)
146
+
%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)
147
+
ret <vscale x 4 x i32> %w
148
+
}
149
+
150
+
; We can't reduce the VL as %v is used as a passthru, i.e. the elements past VL
151
+
; are demanded.
152
+
define <vscale x 4 x i32> @different_vl_as_passthru(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
153
+
; CHECK-LABEL: different_vl_as_passthru:
154
+
; CHECK: # %bb.0:
155
+
; CHECK-NEXT: vsetvli zero, a0, e32, m2, tu, ma
156
+
; CHECK-NEXT: vmv2r.v v12, v8
157
+
; CHECK-NEXT: vadd.vv v12, v8, v10
158
+
; CHECK-NEXT: vsetvli zero, a1, e32, m2, tu, ma
159
+
; CHECK-NEXT: vadd.vv v12, v8, v10
160
+
; CHECK-NEXT: vmv2r.v v8, v12
161
+
; CHECK-NEXT: ret
162
+
%v = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1)
163
+
%w = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> %v, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl2)
164
+
ret <vscale x 4 x i32> %w
165
+
}
166
+
167
+
; We can't reduce the VL as %v is used as a passthru, i.e. the elements past VL
168
+
; are demanded.
169
+
define <vscale x 4 x i32> @different_imm_vl_as_passthru(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl1, iXLen %vl2) {
170
+
; CHECK-LABEL: different_imm_vl_as_passthru:
128
171
; CHECK: # %bb.0:
129
172
; CHECK-NEXT: vsetivli zero, 5, e32, m2, tu, ma
130
-
; CHECK-NEXT: vmv2r.v v14, v10
131
-
; CHECK-NEXT: vadd.vv v14, v10, v12
173
+
; CHECK-NEXT: vmv2r.v v12, v8
174
+
; CHECK-NEXT: vadd.vv v12, v8, v10
132
175
; CHECK-NEXT: vsetivli zero, 4, e32, m2, tu, ma
133
-
; CHECK-NEXT: vadd.vv v8, v14, v10
176
+
; CHECK-NEXT: vadd.vv v12, v8, v10
177
+
; CHECK-NEXT: vmv2r.v v8, v12
134
178
; CHECK-NEXT: ret
135
179
%v = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen 5)
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)
180
+
%w = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> %v, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen 4)
0 commit comments