1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=riscv64 -mattr=+v,+zvl256b | FileCheck %s
4 declare <8 x i16> @llvm.vp.merge.v8i16(<8 x i1>, <8 x i16>, <8 x i16>, i32)
5 declare <8 x i32> @llvm.vp.merge.v8i32(<8 x i1>, <8 x i32>, <8 x i32>, i32)
6 declare <8 x float> @llvm.vp.merge.v8f32(<8 x i1>, <8 x float>, <8 x float>, i32)
7 declare <8 x double> @llvm.vp.merge.v8f64(<8 x i1>, <8 x double>, <8 x double>, i32)
9 ; Test binary operator with vp.merge and vp.smax.
10 declare <8 x i32> @llvm.vp.add.v8i32(<8 x i32>, <8 x i32>, <8 x i1>, i32)
11 define <8 x i32> @vpmerge_vpadd(<8 x i32> %passthru, <8 x i32> %x, <8 x i32> %y, <8 x i1> %m, i32 zeroext %vl) {
12 ; CHECK-LABEL: vpmerge_vpadd:
14 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
15 ; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t
17 %a = call <8 x i32> @llvm.vp.add.v8i32(<8 x i32> %x, <8 x i32> %y, <8 x i1> splat (i1 true), i32 %vl)
18 %b = call <8 x i32> @llvm.vp.merge.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
22 ; Test glued node of merge should not be deleted.
23 declare <8 x i1> @llvm.vp.icmp.v8i32(<8 x i32>, <8 x i32>, metadata, <8 x i1>, i32)
24 define <8 x i32> @vpmerge_vpadd2(<8 x i32> %passthru, <8 x i32> %x, <8 x i32> %y, i32 zeroext %vl) {
25 ; CHECK-LABEL: vpmerge_vpadd2:
27 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
28 ; CHECK-NEXT: vmseq.vv v0, v9, v10
29 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, tu, mu
30 ; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t
32 %a = call <8 x i32> @llvm.vp.add.v8i32(<8 x i32> %x, <8 x i32> %y, <8 x i1> splat (i1 true), i32 %vl)
33 %m = call <8 x i1> @llvm.vp.icmp.v8i32(<8 x i32> %x, <8 x i32> %y, metadata !"eq", <8 x i1> splat (i1 true), i32 %vl)
34 %b = call <8 x i32> @llvm.vp.merge.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
38 ; Test vp.merge have all-ones mask.
39 define <8 x i32> @vpmerge_vpadd3(<8 x i32> %passthru, <8 x i32> %x, <8 x i32> %y, i32 zeroext %vl) {
40 ; CHECK-LABEL: vpmerge_vpadd3:
42 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, ma
43 ; CHECK-NEXT: vadd.vv v8, v9, v10
45 %a = call <8 x i32> @llvm.vp.add.v8i32(<8 x i32> %x, <8 x i32> %y, <8 x i1> splat (i1 true), i32 %vl)
46 %b = call <8 x i32> @llvm.vp.merge.v8i32(<8 x i1> splat (i1 true), <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
50 ; Test float binary operator with vp.merge and vp.fadd.
51 declare <8 x float> @llvm.vp.fadd.v8f32(<8 x float>, <8 x float>, <8 x i1>, i32)
52 define <8 x float> @vpmerge_vpfadd(<8 x float> %passthru, <8 x float> %x, <8 x float> %y, <8 x i1> %m, i32 zeroext %vl) {
53 ; CHECK-LABEL: vpmerge_vpfadd:
55 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
56 ; CHECK-NEXT: vfadd.vv v8, v9, v10, v0.t
58 %a = call <8 x float> @llvm.vp.fadd.v8f32(<8 x float> %x, <8 x float> %y, <8 x i1> splat (i1 true), i32 %vl)
59 %b = call <8 x float> @llvm.vp.merge.v8f32(<8 x i1> %m, <8 x float> %a, <8 x float> %passthru, i32 %vl)
63 ; Test conversion by fptosi.
64 declare <8 x i16> @llvm.vp.fptosi.v8i16.v8f32(<8 x float>, <8 x i1>, i32)
65 define <8 x i16> @vpmerge_vpfptosi(<8 x i16> %passthru, <8 x float> %x, <8 x i1> %m, i32 zeroext %vl) {
66 ; CHECK-LABEL: vpmerge_vpfptosi:
68 ; CHECK-NEXT: vsetvli zero, a0, e16, mf2, tu, mu
69 ; CHECK-NEXT: vfncvt.rtz.x.f.w v8, v9, v0.t
71 %a = call <8 x i16> @llvm.vp.fptosi.v8i16.v8f32(<8 x float> %x, <8 x i1> splat (i1 true), i32 %vl)
72 %b = call <8 x i16> @llvm.vp.merge.v8i16(<8 x i1> %m, <8 x i16> %a, <8 x i16> %passthru, i32 %vl)
76 ; Test conversion by sitofp.
77 declare <8 x float> @llvm.vp.sitofp.v8f32.v8i64(<8 x i64>, <8 x i1>, i32)
78 define <8 x float> @vpmerge_vpsitofp(<8 x float> %passthru, <8 x i64> %x, <8 x i1> %m, i32 zeroext %vl) {
79 ; CHECK-LABEL: vpmerge_vpsitofp:
81 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
82 ; CHECK-NEXT: vfncvt.f.x.w v8, v10, v0.t
84 %a = call <8 x float> @llvm.vp.sitofp.v8f32.v8i64(<8 x i64> %x, <8 x i1> splat (i1 true), i32 %vl)
85 %b = call <8 x float> @llvm.vp.merge.v8f32(<8 x i1> %m, <8 x float> %a, <8 x float> %passthru, i32 %vl)
89 ; Test integer extension by vp.zext.
90 declare <8 x i32> @llvm.vp.zext.v8i32.v8i8(<8 x i8>, <8 x i1>, i32)
91 define <8 x i32> @vpmerge_vpzext(<8 x i32> %passthru, <8 x i8> %x, <8 x i1> %m, i32 zeroext %vl) {
92 ; CHECK-LABEL: vpmerge_vpzext:
94 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
95 ; CHECK-NEXT: vzext.vf4 v8, v9, v0.t
97 %a = call <8 x i32> @llvm.vp.zext.v8i32.v8i8(<8 x i8> %x, <8 x i1> splat (i1 true), i32 %vl)
98 %b = call <8 x i32> @llvm.vp.merge.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
102 ; Test integer truncation by vp.trunc.
103 declare <8 x i32> @llvm.vp.trunc.v8i32.v8i64(<8 x i64>, <8 x i1>, i32)
104 define <8 x i32> @vpmerge_vptrunc(<8 x i32> %passthru, <8 x i64> %x, <8 x i1> %m, i32 zeroext %vl) {
105 ; CHECK-LABEL: vpmerge_vptrunc:
107 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
108 ; CHECK-NEXT: vnsrl.wi v8, v10, 0, v0.t
110 %a = call <8 x i32> @llvm.vp.trunc.v8i32.v8i64(<8 x i64> %x, <8 x i1> splat (i1 true), i32 %vl)
111 %b = call <8 x i32> @llvm.vp.merge.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
115 ; Test integer extension by vp.fpext.
116 declare <8 x double> @llvm.vp.fpext.v8f64.v8f32(<8 x float>, <8 x i1>, i32)
117 define <8 x double> @vpmerge_vpfpext(<8 x double> %passthru, <8 x float> %x, <8 x i1> %m, i32 zeroext %vl) {
118 ; CHECK-LABEL: vpmerge_vpfpext:
120 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
121 ; CHECK-NEXT: vfwcvt.f.f.v v8, v10, v0.t
123 %a = call <8 x double> @llvm.vp.fpext.v8f64.v8f32(<8 x float> %x, <8 x i1> splat (i1 true), i32 %vl)
124 %b = call <8 x double> @llvm.vp.merge.v8f64(<8 x i1> %m, <8 x double> %a, <8 x double> %passthru, i32 %vl)
128 ; Test integer truncation by vp.trunc.
129 declare <8 x float> @llvm.vp.fptrunc.v8f32.v8f64(<8 x double>, <8 x i1>, i32)
130 define <8 x float> @vpmerge_vpfptrunc(<8 x float> %passthru, <8 x double> %x, <8 x i1> %m, i32 zeroext %vl) {
131 ; CHECK-LABEL: vpmerge_vpfptrunc:
133 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
134 ; CHECK-NEXT: vfncvt.f.f.w v8, v10, v0.t
136 %a = call <8 x float> @llvm.vp.fptrunc.v8f32.v8f64(<8 x double> %x, <8 x i1> splat (i1 true), i32 %vl)
137 %b = call <8 x float> @llvm.vp.merge.v8f32(<8 x i1> %m, <8 x float> %a, <8 x float> %passthru, i32 %vl)
141 ; Test load operation by vp.load.
142 declare <8 x i32> @llvm.vp.load.v8i32.p0(ptr, <8 x i1>, i32)
144 define <8 x i32> @vpmerge_vpload(<8 x i32> %passthru, ptr %p, <8 x i1> %m, i32 zeroext %vl) {
145 ; CHECK-LABEL: vpmerge_vpload:
147 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, tu, mu
148 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
150 %a = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %p, <8 x i1> splat (i1 true), i32 %vl)
151 %b = call <8 x i32> @llvm.vp.merge.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
155 ; Test result have chain and glued node.
156 define <8 x i32> @vpmerge_vpload2(<8 x i32> %passthru, ptr %p, <8 x i32> %x, <8 x i32> %y, i32 zeroext %vl) {
157 ; CHECK-LABEL: vpmerge_vpload2:
159 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, ma
160 ; CHECK-NEXT: vmseq.vv v0, v9, v10
161 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, tu, mu
162 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
164 %a = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %p, <8 x i1> splat (i1 true), i32 %vl)
165 %m = call <8 x i1> @llvm.vp.icmp.v8i32(<8 x i32> %x, <8 x i32> %y, metadata !"eq", <8 x i1> splat (i1 true), i32 %vl)
166 %b = call <8 x i32> @llvm.vp.merge.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
170 declare <8 x i16> @llvm.vp.select.v8i16(<8 x i1>, <8 x i16>, <8 x i16>, i32)
171 declare <8 x i32> @llvm.vp.select.v8i32(<8 x i1>, <8 x i32>, <8 x i32>, i32)
172 declare <8 x float> @llvm.vp.select.v8f32(<8 x i1>, <8 x float>, <8 x float>, i32)
173 declare <8 x double> @llvm.vp.select.v8f64(<8 x i1>, <8 x double>, <8 x double>, i32)
175 ; Test binary operator with vp.select and vp.add.
176 define <8 x i32> @vpselect_vpadd(<8 x i32> %passthru, <8 x i32> %x, <8 x i32> %y, <8 x i1> %m, i32 zeroext %vl) {
177 ; CHECK-LABEL: vpselect_vpadd:
179 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
180 ; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t
182 %a = call <8 x i32> @llvm.vp.add.v8i32(<8 x i32> %x, <8 x i32> %y, <8 x i1> splat (i1 true), i32 %vl)
183 %b = call <8 x i32> @llvm.vp.select.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
187 ; Test glued node of select should not be deleted.
188 define <8 x i32> @vpselect_vpadd2(<8 x i32> %passthru, <8 x i32> %x, <8 x i32> %y, i32 zeroext %vl) {
189 ; CHECK-LABEL: vpselect_vpadd2:
191 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
192 ; CHECK-NEXT: vmseq.vv v0, v9, v10
193 ; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t
195 %a = call <8 x i32> @llvm.vp.add.v8i32(<8 x i32> %x, <8 x i32> %y, <8 x i1> splat (i1 true), i32 %vl)
196 %m = call <8 x i1> @llvm.vp.icmp.v8i32(<8 x i32> %x, <8 x i32> %y, metadata !"eq", <8 x i1> splat (i1 true), i32 %vl)
197 %b = call <8 x i32> @llvm.vp.select.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
201 ; Test vp.select have all-ones mask.
202 define <8 x i32> @vpselect_vpadd3(<8 x i32> %passthru, <8 x i32> %x, <8 x i32> %y, i32 zeroext %vl) {
203 ; CHECK-LABEL: vpselect_vpadd3:
205 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
206 ; CHECK-NEXT: vadd.vv v8, v9, v10
208 %a = call <8 x i32> @llvm.vp.add.v8i32(<8 x i32> %x, <8 x i32> %y, <8 x i1> splat (i1 true), i32 %vl)
209 %b = call <8 x i32> @llvm.vp.select.v8i32(<8 x i1> splat (i1 true), <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
213 ; Test float binary operator with vp.select and vp.fadd.
214 define <8 x float> @vpselect_vpfadd(<8 x float> %passthru, <8 x float> %x, <8 x float> %y, <8 x i1> %m, i32 zeroext %vl) {
215 ; CHECK-LABEL: vpselect_vpfadd:
217 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
218 ; CHECK-NEXT: vfadd.vv v8, v9, v10, v0.t
220 %a = call <8 x float> @llvm.vp.fadd.v8f32(<8 x float> %x, <8 x float> %y, <8 x i1> splat (i1 true), i32 %vl)
221 %b = call <8 x float> @llvm.vp.select.v8f32(<8 x i1> %m, <8 x float> %a, <8 x float> %passthru, i32 %vl)
225 ; Test conversion by fptosi.
226 define <8 x i16> @vpselect_vpfptosi(<8 x i16> %passthru, <8 x float> %x, <8 x i1> %m, i32 zeroext %vl) {
227 ; CHECK-LABEL: vpselect_vpfptosi:
229 ; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, mu
230 ; CHECK-NEXT: vfncvt.rtz.x.f.w v8, v9, v0.t
232 %a = call <8 x i16> @llvm.vp.fptosi.v8i16.v8f32(<8 x float> %x, <8 x i1> splat (i1 true), i32 %vl)
233 %b = call <8 x i16> @llvm.vp.select.v8i16(<8 x i1> %m, <8 x i16> %a, <8 x i16> %passthru, i32 %vl)
237 ; Test conversion by sitofp.
238 define <8 x float> @vpselect_vpsitofp(<8 x float> %passthru, <8 x i64> %x, <8 x i1> %m, i32 zeroext %vl) {
239 ; CHECK-LABEL: vpselect_vpsitofp:
241 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
242 ; CHECK-NEXT: vfncvt.f.x.w v8, v10, v0.t
244 %a = call <8 x float> @llvm.vp.sitofp.v8f32.v8i64(<8 x i64> %x, <8 x i1> splat (i1 true), i32 %vl)
245 %b = call <8 x float> @llvm.vp.select.v8f32(<8 x i1> %m, <8 x float> %a, <8 x float> %passthru, i32 %vl)
249 ; Test integer extension by vp.zext.
250 define <8 x i32> @vpselect_vpzext(<8 x i32> %passthru, <8 x i8> %x, <8 x i1> %m, i32 zeroext %vl) {
251 ; CHECK-LABEL: vpselect_vpzext:
253 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
254 ; CHECK-NEXT: vzext.vf4 v8, v9, v0.t
256 %a = call <8 x i32> @llvm.vp.zext.v8i32.v8i8(<8 x i8> %x, <8 x i1> splat (i1 true), i32 %vl)
257 %b = call <8 x i32> @llvm.vp.select.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
261 ; Test integer truncation by vp.trunc.
262 define <8 x i32> @vpselect_vptrunc(<8 x i32> %passthru, <8 x i64> %x, <8 x i1> %m, i32 zeroext %vl) {
263 ; CHECK-LABEL: vpselect_vptrunc:
265 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
266 ; CHECK-NEXT: vnsrl.wi v8, v10, 0, v0.t
268 %a = call <8 x i32> @llvm.vp.trunc.v8i32.v8i64(<8 x i64> %x, <8 x i1> splat (i1 true), i32 %vl)
269 %b = call <8 x i32> @llvm.vp.select.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
273 ; Test integer extension by vp.fpext.
274 define <8 x double> @vpselect_vpfpext(<8 x double> %passthru, <8 x float> %x, <8 x i1> %m, i32 zeroext %vl) {
275 ; CHECK-LABEL: vpselect_vpfpext:
277 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
278 ; CHECK-NEXT: vfwcvt.f.f.v v8, v10, v0.t
280 %a = call <8 x double> @llvm.vp.fpext.v8f64.v8f32(<8 x float> %x, <8 x i1> splat (i1 true), i32 %vl)
281 %b = call <8 x double> @llvm.vp.select.v8f64(<8 x i1> %m, <8 x double> %a, <8 x double> %passthru, i32 %vl)
285 ; Test integer truncation by vp.trunc.
286 define <8 x float> @vpselect_vpfptrunc(<8 x float> %passthru, <8 x double> %x, <8 x i1> %m, i32 zeroext %vl) {
287 ; CHECK-LABEL: vpselect_vpfptrunc:
289 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu
290 ; CHECK-NEXT: vfncvt.f.f.w v8, v10, v0.t
292 %a = call <8 x float> @llvm.vp.fptrunc.v8f32.v8f64(<8 x double> %x, <8 x i1> splat (i1 true), i32 %vl)
293 %b = call <8 x float> @llvm.vp.select.v8f32(<8 x i1> %m, <8 x float> %a, <8 x float> %passthru, i32 %vl)
297 ; Test load operation by vp.load.
298 define <8 x i32> @vpselect_vpload(<8 x i32> %passthru, ptr %p, <8 x i1> %m, i32 zeroext %vl) {
299 ; CHECK-LABEL: vpselect_vpload:
301 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, mu
302 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
304 %a = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %p, <8 x i1> splat (i1 true), i32 %vl)
305 %b = call <8 x i32> @llvm.vp.select.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)
309 ; Test result have chain and glued node.
310 define <8 x i32> @vpselect_vpload2(<8 x i32> %passthru, ptr %p, <8 x i32> %x, <8 x i32> %y, i32 zeroext %vl) {
311 ; CHECK-LABEL: vpselect_vpload2:
313 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, mu
314 ; CHECK-NEXT: vmseq.vv v0, v9, v10
315 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
317 %a = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %p, <8 x i1> splat (i1 true), i32 %vl)
318 %m = call <8 x i1> @llvm.vp.icmp.v8i32(<8 x i32> %x, <8 x i32> %y, metadata !"eq", <8 x i1> splat (i1 true), i32 %vl)
319 %b = call <8 x i32> @llvm.vp.select.v8i32(<8 x i1> %m, <8 x i32> %a, <8 x i32> %passthru, i32 %vl)