1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v,+m -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v,+m -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK
7 declare <vscale x 1 x i8> @llvm.vp.abs.nxv1i8(<vscale x 1 x i8>, i1 immarg, <vscale x 1 x i1>, i32)
9 define <vscale x 1 x i8> @vp_abs_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i1> %m, i32 zeroext %evl) {
10 ; CHECK-LABEL: vp_abs_nxv1i8:
12 ; CHECK-NEXT: vsetvli zero, a0, e8, mf8, ta, ma
13 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
14 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
16 %v = call <vscale x 1 x i8> @llvm.vp.abs.nxv1i8(<vscale x 1 x i8> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
17 ret <vscale x 1 x i8> %v
20 define <vscale x 1 x i8> @vp_abs_nxv1i8_unmasked(<vscale x 1 x i8> %va, i32 zeroext %evl) {
21 ; CHECK-LABEL: vp_abs_nxv1i8_unmasked:
23 ; CHECK-NEXT: vsetvli zero, a0, e8, mf8, ta, ma
24 ; CHECK-NEXT: vrsub.vi v9, v8, 0
25 ; CHECK-NEXT: vmax.vv v8, v8, v9
27 %head = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
28 %m = shufflevector <vscale x 1 x i1> %head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
29 %v = call <vscale x 1 x i8> @llvm.vp.abs.nxv1i8(<vscale x 1 x i8> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
30 ret <vscale x 1 x i8> %v
33 declare <vscale x 2 x i8> @llvm.vp.abs.nxv2i8(<vscale x 2 x i8>, i1 immarg, <vscale x 2 x i1>, i32)
35 define <vscale x 2 x i8> @vp_abs_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i1> %m, i32 zeroext %evl) {
36 ; CHECK-LABEL: vp_abs_nxv2i8:
38 ; CHECK-NEXT: vsetvli zero, a0, e8, mf4, ta, ma
39 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
40 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
42 %v = call <vscale x 2 x i8> @llvm.vp.abs.nxv2i8(<vscale x 2 x i8> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
43 ret <vscale x 2 x i8> %v
46 define <vscale x 2 x i8> @vp_abs_nxv2i8_unmasked(<vscale x 2 x i8> %va, i32 zeroext %evl) {
47 ; CHECK-LABEL: vp_abs_nxv2i8_unmasked:
49 ; CHECK-NEXT: vsetvli zero, a0, e8, mf4, ta, ma
50 ; CHECK-NEXT: vrsub.vi v9, v8, 0
51 ; CHECK-NEXT: vmax.vv v8, v8, v9
53 %head = insertelement <vscale x 2 x i1> poison, i1 true, i32 0
54 %m = shufflevector <vscale x 2 x i1> %head, <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
55 %v = call <vscale x 2 x i8> @llvm.vp.abs.nxv2i8(<vscale x 2 x i8> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
56 ret <vscale x 2 x i8> %v
59 declare <vscale x 4 x i8> @llvm.vp.abs.nxv4i8(<vscale x 4 x i8>, i1 immarg, <vscale x 4 x i1>, i32)
61 define <vscale x 4 x i8> @vp_abs_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i1> %m, i32 zeroext %evl) {
62 ; CHECK-LABEL: vp_abs_nxv4i8:
64 ; CHECK-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
65 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
66 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
68 %v = call <vscale x 4 x i8> @llvm.vp.abs.nxv4i8(<vscale x 4 x i8> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
69 ret <vscale x 4 x i8> %v
72 define <vscale x 4 x i8> @vp_abs_nxv4i8_unmasked(<vscale x 4 x i8> %va, i32 zeroext %evl) {
73 ; CHECK-LABEL: vp_abs_nxv4i8_unmasked:
75 ; CHECK-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
76 ; CHECK-NEXT: vrsub.vi v9, v8, 0
77 ; CHECK-NEXT: vmax.vv v8, v8, v9
79 %head = insertelement <vscale x 4 x i1> poison, i1 true, i32 0
80 %m = shufflevector <vscale x 4 x i1> %head, <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer
81 %v = call <vscale x 4 x i8> @llvm.vp.abs.nxv4i8(<vscale x 4 x i8> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
82 ret <vscale x 4 x i8> %v
85 declare <vscale x 8 x i8> @llvm.vp.abs.nxv8i8(<vscale x 8 x i8>, i1 immarg, <vscale x 8 x i1>, i32)
87 define <vscale x 8 x i8> @vp_abs_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i1> %m, i32 zeroext %evl) {
88 ; CHECK-LABEL: vp_abs_nxv8i8:
90 ; CHECK-NEXT: vsetvli zero, a0, e8, m1, ta, ma
91 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
92 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
94 %v = call <vscale x 8 x i8> @llvm.vp.abs.nxv8i8(<vscale x 8 x i8> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
95 ret <vscale x 8 x i8> %v
98 define <vscale x 8 x i8> @vp_abs_nxv8i8_unmasked(<vscale x 8 x i8> %va, i32 zeroext %evl) {
99 ; CHECK-LABEL: vp_abs_nxv8i8_unmasked:
101 ; CHECK-NEXT: vsetvli zero, a0, e8, m1, ta, ma
102 ; CHECK-NEXT: vrsub.vi v9, v8, 0
103 ; CHECK-NEXT: vmax.vv v8, v8, v9
105 %head = insertelement <vscale x 8 x i1> poison, i1 true, i32 0
106 %m = shufflevector <vscale x 8 x i1> %head, <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
107 %v = call <vscale x 8 x i8> @llvm.vp.abs.nxv8i8(<vscale x 8 x i8> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
108 ret <vscale x 8 x i8> %v
111 declare <vscale x 16 x i8> @llvm.vp.abs.nxv16i8(<vscale x 16 x i8>, i1 immarg, <vscale x 16 x i1>, i32)
113 define <vscale x 16 x i8> @vp_abs_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i1> %m, i32 zeroext %evl) {
114 ; CHECK-LABEL: vp_abs_nxv16i8:
116 ; CHECK-NEXT: vsetvli zero, a0, e8, m2, ta, ma
117 ; CHECK-NEXT: vrsub.vi v10, v8, 0, v0.t
118 ; CHECK-NEXT: vmax.vv v8, v8, v10, v0.t
120 %v = call <vscale x 16 x i8> @llvm.vp.abs.nxv16i8(<vscale x 16 x i8> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
121 ret <vscale x 16 x i8> %v
124 define <vscale x 16 x i8> @vp_abs_nxv16i8_unmasked(<vscale x 16 x i8> %va, i32 zeroext %evl) {
125 ; CHECK-LABEL: vp_abs_nxv16i8_unmasked:
127 ; CHECK-NEXT: vsetvli zero, a0, e8, m2, ta, ma
128 ; CHECK-NEXT: vrsub.vi v10, v8, 0
129 ; CHECK-NEXT: vmax.vv v8, v8, v10
131 %head = insertelement <vscale x 16 x i1> poison, i1 true, i32 0
132 %m = shufflevector <vscale x 16 x i1> %head, <vscale x 16 x i1> poison, <vscale x 16 x i32> zeroinitializer
133 %v = call <vscale x 16 x i8> @llvm.vp.abs.nxv16i8(<vscale x 16 x i8> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
134 ret <vscale x 16 x i8> %v
137 declare <vscale x 32 x i8> @llvm.vp.abs.nxv32i8(<vscale x 32 x i8>, i1 immarg, <vscale x 32 x i1>, i32)
139 define <vscale x 32 x i8> @vp_abs_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i1> %m, i32 zeroext %evl) {
140 ; CHECK-LABEL: vp_abs_nxv32i8:
142 ; CHECK-NEXT: vsetvli zero, a0, e8, m4, ta, ma
143 ; CHECK-NEXT: vrsub.vi v12, v8, 0, v0.t
144 ; CHECK-NEXT: vmax.vv v8, v8, v12, v0.t
146 %v = call <vscale x 32 x i8> @llvm.vp.abs.nxv32i8(<vscale x 32 x i8> %va, i1 false, <vscale x 32 x i1> %m, i32 %evl)
147 ret <vscale x 32 x i8> %v
150 define <vscale x 32 x i8> @vp_abs_nxv32i8_unmasked(<vscale x 32 x i8> %va, i32 zeroext %evl) {
151 ; CHECK-LABEL: vp_abs_nxv32i8_unmasked:
153 ; CHECK-NEXT: vsetvli zero, a0, e8, m4, ta, ma
154 ; CHECK-NEXT: vrsub.vi v12, v8, 0
155 ; CHECK-NEXT: vmax.vv v8, v8, v12
157 %head = insertelement <vscale x 32 x i1> poison, i1 true, i32 0
158 %m = shufflevector <vscale x 32 x i1> %head, <vscale x 32 x i1> poison, <vscale x 32 x i32> zeroinitializer
159 %v = call <vscale x 32 x i8> @llvm.vp.abs.nxv32i8(<vscale x 32 x i8> %va, i1 false, <vscale x 32 x i1> %m, i32 %evl)
160 ret <vscale x 32 x i8> %v
163 declare <vscale x 64 x i8> @llvm.vp.abs.nxv64i8(<vscale x 64 x i8>, i1 immarg, <vscale x 64 x i1>, i32)
165 define <vscale x 64 x i8> @vp_abs_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i1> %m, i32 zeroext %evl) {
166 ; CHECK-LABEL: vp_abs_nxv64i8:
168 ; CHECK-NEXT: vsetvli zero, a0, e8, m8, ta, ma
169 ; CHECK-NEXT: vrsub.vi v16, v8, 0, v0.t
170 ; CHECK-NEXT: vmax.vv v8, v8, v16, v0.t
172 %v = call <vscale x 64 x i8> @llvm.vp.abs.nxv64i8(<vscale x 64 x i8> %va, i1 false, <vscale x 64 x i1> %m, i32 %evl)
173 ret <vscale x 64 x i8> %v
176 define <vscale x 64 x i8> @vp_abs_nxv64i8_unmasked(<vscale x 64 x i8> %va, i32 zeroext %evl) {
177 ; CHECK-LABEL: vp_abs_nxv64i8_unmasked:
179 ; CHECK-NEXT: vsetvli zero, a0, e8, m8, ta, ma
180 ; CHECK-NEXT: vrsub.vi v16, v8, 0
181 ; CHECK-NEXT: vmax.vv v8, v8, v16
183 %head = insertelement <vscale x 64 x i1> poison, i1 true, i32 0
184 %m = shufflevector <vscale x 64 x i1> %head, <vscale x 64 x i1> poison, <vscale x 64 x i32> zeroinitializer
185 %v = call <vscale x 64 x i8> @llvm.vp.abs.nxv64i8(<vscale x 64 x i8> %va, i1 false, <vscale x 64 x i1> %m, i32 %evl)
186 ret <vscale x 64 x i8> %v
189 declare <vscale x 1 x i16> @llvm.vp.abs.nxv1i16(<vscale x 1 x i16>, i1 immarg, <vscale x 1 x i1>, i32)
191 define <vscale x 1 x i16> @vp_abs_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i1> %m, i32 zeroext %evl) {
192 ; CHECK-LABEL: vp_abs_nxv1i16:
194 ; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
195 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
196 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
198 %v = call <vscale x 1 x i16> @llvm.vp.abs.nxv1i16(<vscale x 1 x i16> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
199 ret <vscale x 1 x i16> %v
202 define <vscale x 1 x i16> @vp_abs_nxv1i16_unmasked(<vscale x 1 x i16> %va, i32 zeroext %evl) {
203 ; CHECK-LABEL: vp_abs_nxv1i16_unmasked:
205 ; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
206 ; CHECK-NEXT: vrsub.vi v9, v8, 0
207 ; CHECK-NEXT: vmax.vv v8, v8, v9
209 %head = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
210 %m = shufflevector <vscale x 1 x i1> %head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
211 %v = call <vscale x 1 x i16> @llvm.vp.abs.nxv1i16(<vscale x 1 x i16> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
212 ret <vscale x 1 x i16> %v
215 declare <vscale x 2 x i16> @llvm.vp.abs.nxv2i16(<vscale x 2 x i16>, i1 immarg, <vscale x 2 x i1>, i32)
217 define <vscale x 2 x i16> @vp_abs_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i1> %m, i32 zeroext %evl) {
218 ; CHECK-LABEL: vp_abs_nxv2i16:
220 ; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
221 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
222 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
224 %v = call <vscale x 2 x i16> @llvm.vp.abs.nxv2i16(<vscale x 2 x i16> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
225 ret <vscale x 2 x i16> %v
228 define <vscale x 2 x i16> @vp_abs_nxv2i16_unmasked(<vscale x 2 x i16> %va, i32 zeroext %evl) {
229 ; CHECK-LABEL: vp_abs_nxv2i16_unmasked:
231 ; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
232 ; CHECK-NEXT: vrsub.vi v9, v8, 0
233 ; CHECK-NEXT: vmax.vv v8, v8, v9
235 %head = insertelement <vscale x 2 x i1> poison, i1 true, i32 0
236 %m = shufflevector <vscale x 2 x i1> %head, <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
237 %v = call <vscale x 2 x i16> @llvm.vp.abs.nxv2i16(<vscale x 2 x i16> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
238 ret <vscale x 2 x i16> %v
241 declare <vscale x 4 x i16> @llvm.vp.abs.nxv4i16(<vscale x 4 x i16>, i1 immarg, <vscale x 4 x i1>, i32)
243 define <vscale x 4 x i16> @vp_abs_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i1> %m, i32 zeroext %evl) {
244 ; CHECK-LABEL: vp_abs_nxv4i16:
246 ; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma
247 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
248 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
250 %v = call <vscale x 4 x i16> @llvm.vp.abs.nxv4i16(<vscale x 4 x i16> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
251 ret <vscale x 4 x i16> %v
254 define <vscale x 4 x i16> @vp_abs_nxv4i16_unmasked(<vscale x 4 x i16> %va, i32 zeroext %evl) {
255 ; CHECK-LABEL: vp_abs_nxv4i16_unmasked:
257 ; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma
258 ; CHECK-NEXT: vrsub.vi v9, v8, 0
259 ; CHECK-NEXT: vmax.vv v8, v8, v9
261 %head = insertelement <vscale x 4 x i1> poison, i1 true, i32 0
262 %m = shufflevector <vscale x 4 x i1> %head, <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer
263 %v = call <vscale x 4 x i16> @llvm.vp.abs.nxv4i16(<vscale x 4 x i16> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
264 ret <vscale x 4 x i16> %v
267 declare <vscale x 8 x i16> @llvm.vp.abs.nxv8i16(<vscale x 8 x i16>, i1 immarg, <vscale x 8 x i1>, i32)
269 define <vscale x 8 x i16> @vp_abs_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i1> %m, i32 zeroext %evl) {
270 ; CHECK-LABEL: vp_abs_nxv8i16:
272 ; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma
273 ; CHECK-NEXT: vrsub.vi v10, v8, 0, v0.t
274 ; CHECK-NEXT: vmax.vv v8, v8, v10, v0.t
276 %v = call <vscale x 8 x i16> @llvm.vp.abs.nxv8i16(<vscale x 8 x i16> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
277 ret <vscale x 8 x i16> %v
280 define <vscale x 8 x i16> @vp_abs_nxv8i16_unmasked(<vscale x 8 x i16> %va, i32 zeroext %evl) {
281 ; CHECK-LABEL: vp_abs_nxv8i16_unmasked:
283 ; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma
284 ; CHECK-NEXT: vrsub.vi v10, v8, 0
285 ; CHECK-NEXT: vmax.vv v8, v8, v10
287 %head = insertelement <vscale x 8 x i1> poison, i1 true, i32 0
288 %m = shufflevector <vscale x 8 x i1> %head, <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
289 %v = call <vscale x 8 x i16> @llvm.vp.abs.nxv8i16(<vscale x 8 x i16> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
290 ret <vscale x 8 x i16> %v
293 declare <vscale x 16 x i16> @llvm.vp.abs.nxv16i16(<vscale x 16 x i16>, i1 immarg, <vscale x 16 x i1>, i32)
295 define <vscale x 16 x i16> @vp_abs_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i1> %m, i32 zeroext %evl) {
296 ; CHECK-LABEL: vp_abs_nxv16i16:
298 ; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, ma
299 ; CHECK-NEXT: vrsub.vi v12, v8, 0, v0.t
300 ; CHECK-NEXT: vmax.vv v8, v8, v12, v0.t
302 %v = call <vscale x 16 x i16> @llvm.vp.abs.nxv16i16(<vscale x 16 x i16> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
303 ret <vscale x 16 x i16> %v
306 define <vscale x 16 x i16> @vp_abs_nxv16i16_unmasked(<vscale x 16 x i16> %va, i32 zeroext %evl) {
307 ; CHECK-LABEL: vp_abs_nxv16i16_unmasked:
309 ; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, ma
310 ; CHECK-NEXT: vrsub.vi v12, v8, 0
311 ; CHECK-NEXT: vmax.vv v8, v8, v12
313 %head = insertelement <vscale x 16 x i1> poison, i1 true, i32 0
314 %m = shufflevector <vscale x 16 x i1> %head, <vscale x 16 x i1> poison, <vscale x 16 x i32> zeroinitializer
315 %v = call <vscale x 16 x i16> @llvm.vp.abs.nxv16i16(<vscale x 16 x i16> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
316 ret <vscale x 16 x i16> %v
319 declare <vscale x 32 x i16> @llvm.vp.abs.nxv32i16(<vscale x 32 x i16>, i1 immarg, <vscale x 32 x i1>, i32)
321 define <vscale x 32 x i16> @vp_abs_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i1> %m, i32 zeroext %evl) {
322 ; CHECK-LABEL: vp_abs_nxv32i16:
324 ; CHECK-NEXT: vsetvli zero, a0, e16, m8, ta, ma
325 ; CHECK-NEXT: vrsub.vi v16, v8, 0, v0.t
326 ; CHECK-NEXT: vmax.vv v8, v8, v16, v0.t
328 %v = call <vscale x 32 x i16> @llvm.vp.abs.nxv32i16(<vscale x 32 x i16> %va, i1 false, <vscale x 32 x i1> %m, i32 %evl)
329 ret <vscale x 32 x i16> %v
332 define <vscale x 32 x i16> @vp_abs_nxv32i16_unmasked(<vscale x 32 x i16> %va, i32 zeroext %evl) {
333 ; CHECK-LABEL: vp_abs_nxv32i16_unmasked:
335 ; CHECK-NEXT: vsetvli zero, a0, e16, m8, ta, ma
336 ; CHECK-NEXT: vrsub.vi v16, v8, 0
337 ; CHECK-NEXT: vmax.vv v8, v8, v16
339 %head = insertelement <vscale x 32 x i1> poison, i1 true, i32 0
340 %m = shufflevector <vscale x 32 x i1> %head, <vscale x 32 x i1> poison, <vscale x 32 x i32> zeroinitializer
341 %v = call <vscale x 32 x i16> @llvm.vp.abs.nxv32i16(<vscale x 32 x i16> %va, i1 false, <vscale x 32 x i1> %m, i32 %evl)
342 ret <vscale x 32 x i16> %v
345 declare <vscale x 1 x i32> @llvm.vp.abs.nxv1i32(<vscale x 1 x i32>, i1 immarg, <vscale x 1 x i1>, i32)
347 define <vscale x 1 x i32> @vp_abs_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i1> %m, i32 zeroext %evl) {
348 ; CHECK-LABEL: vp_abs_nxv1i32:
350 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
351 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
352 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
354 %v = call <vscale x 1 x i32> @llvm.vp.abs.nxv1i32(<vscale x 1 x i32> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
355 ret <vscale x 1 x i32> %v
358 define <vscale x 1 x i32> @vp_abs_nxv1i32_unmasked(<vscale x 1 x i32> %va, i32 zeroext %evl) {
359 ; CHECK-LABEL: vp_abs_nxv1i32_unmasked:
361 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
362 ; CHECK-NEXT: vrsub.vi v9, v8, 0
363 ; CHECK-NEXT: vmax.vv v8, v8, v9
365 %head = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
366 %m = shufflevector <vscale x 1 x i1> %head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
367 %v = call <vscale x 1 x i32> @llvm.vp.abs.nxv1i32(<vscale x 1 x i32> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
368 ret <vscale x 1 x i32> %v
371 declare <vscale x 2 x i32> @llvm.vp.abs.nxv2i32(<vscale x 2 x i32>, i1 immarg, <vscale x 2 x i1>, i32)
373 define <vscale x 2 x i32> @vp_abs_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i1> %m, i32 zeroext %evl) {
374 ; CHECK-LABEL: vp_abs_nxv2i32:
376 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
377 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
378 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
380 %v = call <vscale x 2 x i32> @llvm.vp.abs.nxv2i32(<vscale x 2 x i32> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
381 ret <vscale x 2 x i32> %v
384 define <vscale x 2 x i32> @vp_abs_nxv2i32_unmasked(<vscale x 2 x i32> %va, i32 zeroext %evl) {
385 ; CHECK-LABEL: vp_abs_nxv2i32_unmasked:
387 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
388 ; CHECK-NEXT: vrsub.vi v9, v8, 0
389 ; CHECK-NEXT: vmax.vv v8, v8, v9
391 %head = insertelement <vscale x 2 x i1> poison, i1 true, i32 0
392 %m = shufflevector <vscale x 2 x i1> %head, <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
393 %v = call <vscale x 2 x i32> @llvm.vp.abs.nxv2i32(<vscale x 2 x i32> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
394 ret <vscale x 2 x i32> %v
397 declare <vscale x 4 x i32> @llvm.vp.abs.nxv4i32(<vscale x 4 x i32>, i1 immarg, <vscale x 4 x i1>, i32)
399 define <vscale x 4 x i32> @vp_abs_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i1> %m, i32 zeroext %evl) {
400 ; CHECK-LABEL: vp_abs_nxv4i32:
402 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
403 ; CHECK-NEXT: vrsub.vi v10, v8, 0, v0.t
404 ; CHECK-NEXT: vmax.vv v8, v8, v10, v0.t
406 %v = call <vscale x 4 x i32> @llvm.vp.abs.nxv4i32(<vscale x 4 x i32> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
407 ret <vscale x 4 x i32> %v
410 define <vscale x 4 x i32> @vp_abs_nxv4i32_unmasked(<vscale x 4 x i32> %va, i32 zeroext %evl) {
411 ; CHECK-LABEL: vp_abs_nxv4i32_unmasked:
413 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
414 ; CHECK-NEXT: vrsub.vi v10, v8, 0
415 ; CHECK-NEXT: vmax.vv v8, v8, v10
417 %head = insertelement <vscale x 4 x i1> poison, i1 true, i32 0
418 %m = shufflevector <vscale x 4 x i1> %head, <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer
419 %v = call <vscale x 4 x i32> @llvm.vp.abs.nxv4i32(<vscale x 4 x i32> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
420 ret <vscale x 4 x i32> %v
423 declare <vscale x 8 x i32> @llvm.vp.abs.nxv8i32(<vscale x 8 x i32>, i1 immarg, <vscale x 8 x i1>, i32)
425 define <vscale x 8 x i32> @vp_abs_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i1> %m, i32 zeroext %evl) {
426 ; CHECK-LABEL: vp_abs_nxv8i32:
428 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
429 ; CHECK-NEXT: vrsub.vi v12, v8, 0, v0.t
430 ; CHECK-NEXT: vmax.vv v8, v8, v12, v0.t
432 %v = call <vscale x 8 x i32> @llvm.vp.abs.nxv8i32(<vscale x 8 x i32> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
433 ret <vscale x 8 x i32> %v
436 define <vscale x 8 x i32> @vp_abs_nxv8i32_unmasked(<vscale x 8 x i32> %va, i32 zeroext %evl) {
437 ; CHECK-LABEL: vp_abs_nxv8i32_unmasked:
439 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
440 ; CHECK-NEXT: vrsub.vi v12, v8, 0
441 ; CHECK-NEXT: vmax.vv v8, v8, v12
443 %head = insertelement <vscale x 8 x i1> poison, i1 true, i32 0
444 %m = shufflevector <vscale x 8 x i1> %head, <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
445 %v = call <vscale x 8 x i32> @llvm.vp.abs.nxv8i32(<vscale x 8 x i32> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
446 ret <vscale x 8 x i32> %v
449 declare <vscale x 16 x i32> @llvm.vp.abs.nxv16i32(<vscale x 16 x i32>, i1 immarg, <vscale x 16 x i1>, i32)
451 define <vscale x 16 x i32> @vp_abs_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i1> %m, i32 zeroext %evl) {
452 ; CHECK-LABEL: vp_abs_nxv16i32:
454 ; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma
455 ; CHECK-NEXT: vrsub.vi v16, v8, 0, v0.t
456 ; CHECK-NEXT: vmax.vv v8, v8, v16, v0.t
458 %v = call <vscale x 16 x i32> @llvm.vp.abs.nxv16i32(<vscale x 16 x i32> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
459 ret <vscale x 16 x i32> %v
462 define <vscale x 16 x i32> @vp_abs_nxv16i32_unmasked(<vscale x 16 x i32> %va, i32 zeroext %evl) {
463 ; CHECK-LABEL: vp_abs_nxv16i32_unmasked:
465 ; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma
466 ; CHECK-NEXT: vrsub.vi v16, v8, 0
467 ; CHECK-NEXT: vmax.vv v8, v8, v16
469 %head = insertelement <vscale x 16 x i1> poison, i1 true, i32 0
470 %m = shufflevector <vscale x 16 x i1> %head, <vscale x 16 x i1> poison, <vscale x 16 x i32> zeroinitializer
471 %v = call <vscale x 16 x i32> @llvm.vp.abs.nxv16i32(<vscale x 16 x i32> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
472 ret <vscale x 16 x i32> %v
475 declare <vscale x 1 x i64> @llvm.vp.abs.nxv1i64(<vscale x 1 x i64>, i1 immarg, <vscale x 1 x i1>, i32)
477 define <vscale x 1 x i64> @vp_abs_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i1> %m, i32 zeroext %evl) {
478 ; CHECK-LABEL: vp_abs_nxv1i64:
480 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
481 ; CHECK-NEXT: vrsub.vi v9, v8, 0, v0.t
482 ; CHECK-NEXT: vmax.vv v8, v8, v9, v0.t
484 %v = call <vscale x 1 x i64> @llvm.vp.abs.nxv1i64(<vscale x 1 x i64> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
485 ret <vscale x 1 x i64> %v
488 define <vscale x 1 x i64> @vp_abs_nxv1i64_unmasked(<vscale x 1 x i64> %va, i32 zeroext %evl) {
489 ; CHECK-LABEL: vp_abs_nxv1i64_unmasked:
491 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
492 ; CHECK-NEXT: vrsub.vi v9, v8, 0
493 ; CHECK-NEXT: vmax.vv v8, v8, v9
495 %head = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
496 %m = shufflevector <vscale x 1 x i1> %head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
497 %v = call <vscale x 1 x i64> @llvm.vp.abs.nxv1i64(<vscale x 1 x i64> %va, i1 false, <vscale x 1 x i1> %m, i32 %evl)
498 ret <vscale x 1 x i64> %v
501 declare <vscale x 2 x i64> @llvm.vp.abs.nxv2i64(<vscale x 2 x i64>, i1 immarg, <vscale x 2 x i1>, i32)
503 define <vscale x 2 x i64> @vp_abs_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i1> %m, i32 zeroext %evl) {
504 ; CHECK-LABEL: vp_abs_nxv2i64:
506 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
507 ; CHECK-NEXT: vrsub.vi v10, v8, 0, v0.t
508 ; CHECK-NEXT: vmax.vv v8, v8, v10, v0.t
510 %v = call <vscale x 2 x i64> @llvm.vp.abs.nxv2i64(<vscale x 2 x i64> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
511 ret <vscale x 2 x i64> %v
514 define <vscale x 2 x i64> @vp_abs_nxv2i64_unmasked(<vscale x 2 x i64> %va, i32 zeroext %evl) {
515 ; CHECK-LABEL: vp_abs_nxv2i64_unmasked:
517 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
518 ; CHECK-NEXT: vrsub.vi v10, v8, 0
519 ; CHECK-NEXT: vmax.vv v8, v8, v10
521 %head = insertelement <vscale x 2 x i1> poison, i1 true, i32 0
522 %m = shufflevector <vscale x 2 x i1> %head, <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
523 %v = call <vscale x 2 x i64> @llvm.vp.abs.nxv2i64(<vscale x 2 x i64> %va, i1 false, <vscale x 2 x i1> %m, i32 %evl)
524 ret <vscale x 2 x i64> %v
527 declare <vscale x 4 x i64> @llvm.vp.abs.nxv4i64(<vscale x 4 x i64>, i1 immarg, <vscale x 4 x i1>, i32)
529 define <vscale x 4 x i64> @vp_abs_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i1> %m, i32 zeroext %evl) {
530 ; CHECK-LABEL: vp_abs_nxv4i64:
532 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
533 ; CHECK-NEXT: vrsub.vi v12, v8, 0, v0.t
534 ; CHECK-NEXT: vmax.vv v8, v8, v12, v0.t
536 %v = call <vscale x 4 x i64> @llvm.vp.abs.nxv4i64(<vscale x 4 x i64> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
537 ret <vscale x 4 x i64> %v
540 define <vscale x 4 x i64> @vp_abs_nxv4i64_unmasked(<vscale x 4 x i64> %va, i32 zeroext %evl) {
541 ; CHECK-LABEL: vp_abs_nxv4i64_unmasked:
543 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
544 ; CHECK-NEXT: vrsub.vi v12, v8, 0
545 ; CHECK-NEXT: vmax.vv v8, v8, v12
547 %head = insertelement <vscale x 4 x i1> poison, i1 true, i32 0
548 %m = shufflevector <vscale x 4 x i1> %head, <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer
549 %v = call <vscale x 4 x i64> @llvm.vp.abs.nxv4i64(<vscale x 4 x i64> %va, i1 false, <vscale x 4 x i1> %m, i32 %evl)
550 ret <vscale x 4 x i64> %v
553 declare <vscale x 7 x i64> @llvm.vp.abs.nxv7i64(<vscale x 7 x i64>, i1 immarg, <vscale x 7 x i1>, i32)
555 define <vscale x 7 x i64> @vp_abs_nxv7i64(<vscale x 7 x i64> %va, <vscale x 7 x i1> %m, i32 zeroext %evl) {
556 ; CHECK-LABEL: vp_abs_nxv7i64:
558 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
559 ; CHECK-NEXT: vrsub.vi v16, v8, 0, v0.t
560 ; CHECK-NEXT: vmax.vv v8, v8, v16, v0.t
562 %v = call <vscale x 7 x i64> @llvm.vp.abs.nxv7i64(<vscale x 7 x i64> %va, i1 false, <vscale x 7 x i1> %m, i32 %evl)
563 ret <vscale x 7 x i64> %v
566 define <vscale x 7 x i64> @vp_abs_nxv7i64_unmasked(<vscale x 7 x i64> %va, i32 zeroext %evl) {
567 ; CHECK-LABEL: vp_abs_nxv7i64_unmasked:
569 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
570 ; CHECK-NEXT: vrsub.vi v16, v8, 0
571 ; CHECK-NEXT: vmax.vv v8, v8, v16
573 %head = insertelement <vscale x 7 x i1> poison, i1 true, i32 0
574 %m = shufflevector <vscale x 7 x i1> %head, <vscale x 7 x i1> poison, <vscale x 7 x i32> zeroinitializer
575 %v = call <vscale x 7 x i64> @llvm.vp.abs.nxv7i64(<vscale x 7 x i64> %va, i1 false, <vscale x 7 x i1> %m, i32 %evl)
576 ret <vscale x 7 x i64> %v
579 declare <vscale x 8 x i64> @llvm.vp.abs.nxv8i64(<vscale x 8 x i64>, i1 immarg, <vscale x 8 x i1>, i32)
581 define <vscale x 8 x i64> @vp_abs_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i1> %m, i32 zeroext %evl) {
582 ; CHECK-LABEL: vp_abs_nxv8i64:
584 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
585 ; CHECK-NEXT: vrsub.vi v16, v8, 0, v0.t
586 ; CHECK-NEXT: vmax.vv v8, v8, v16, v0.t
588 %v = call <vscale x 8 x i64> @llvm.vp.abs.nxv8i64(<vscale x 8 x i64> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
589 ret <vscale x 8 x i64> %v
592 define <vscale x 8 x i64> @vp_abs_nxv8i64_unmasked(<vscale x 8 x i64> %va, i32 zeroext %evl) {
593 ; CHECK-LABEL: vp_abs_nxv8i64_unmasked:
595 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
596 ; CHECK-NEXT: vrsub.vi v16, v8, 0
597 ; CHECK-NEXT: vmax.vv v8, v8, v16
599 %head = insertelement <vscale x 8 x i1> poison, i1 true, i32 0
600 %m = shufflevector <vscale x 8 x i1> %head, <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
601 %v = call <vscale x 8 x i64> @llvm.vp.abs.nxv8i64(<vscale x 8 x i64> %va, i1 false, <vscale x 8 x i1> %m, i32 %evl)
602 ret <vscale x 8 x i64> %v
605 declare <vscale x 16 x i64> @llvm.vp.abs.nxv16i64(<vscale x 16 x i64>, i1 immarg, <vscale x 16 x i1>, i32)
607 define <vscale x 16 x i64> @vp_abs_nxv16i64(<vscale x 16 x i64> %va, <vscale x 16 x i1> %m, i32 zeroext %evl) {
608 ; CHECK-LABEL: vp_abs_nxv16i64:
610 ; CHECK-NEXT: addi sp, sp, -16
611 ; CHECK-NEXT: .cfi_def_cfa_offset 16
612 ; CHECK-NEXT: csrr a1, vlenb
613 ; CHECK-NEXT: slli a1, a1, 4
614 ; CHECK-NEXT: sub sp, sp, a1
615 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 16 * vlenb
616 ; CHECK-NEXT: vmv1r.v v24, v0
617 ; CHECK-NEXT: csrr a1, vlenb
618 ; CHECK-NEXT: slli a1, a1, 3
619 ; CHECK-NEXT: add a1, sp, a1
620 ; CHECK-NEXT: addi a1, a1, 16
621 ; CHECK-NEXT: vs8r.v v8, (a1) # Unknown-size Folded Spill
622 ; CHECK-NEXT: csrr a1, vlenb
623 ; CHECK-NEXT: srli a2, a1, 3
624 ; CHECK-NEXT: vsetvli a3, zero, e8, mf4, ta, ma
625 ; CHECK-NEXT: vslidedown.vx v0, v0, a2
626 ; CHECK-NEXT: sub a2, a0, a1
627 ; CHECK-NEXT: sltu a3, a0, a2
628 ; CHECK-NEXT: addi a3, a3, -1
629 ; CHECK-NEXT: and a2, a3, a2
630 ; CHECK-NEXT: vsetvli zero, a2, e64, m8, ta, ma
631 ; CHECK-NEXT: vrsub.vi v8, v16, 0, v0.t
632 ; CHECK-NEXT: vmax.vv v8, v16, v8, v0.t
633 ; CHECK-NEXT: addi a2, sp, 16
634 ; CHECK-NEXT: vs8r.v v8, (a2) # Unknown-size Folded Spill
635 ; CHECK-NEXT: bltu a0, a1, .LBB46_2
636 ; CHECK-NEXT: # %bb.1:
637 ; CHECK-NEXT: mv a0, a1
638 ; CHECK-NEXT: .LBB46_2:
639 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
640 ; CHECK-NEXT: vmv1r.v v0, v24
641 ; CHECK-NEXT: csrr a0, vlenb
642 ; CHECK-NEXT: slli a0, a0, 3
643 ; CHECK-NEXT: add a0, sp, a0
644 ; CHECK-NEXT: addi a0, a0, 16
645 ; CHECK-NEXT: vl8r.v v8, (a0) # Unknown-size Folded Reload
646 ; CHECK-NEXT: vrsub.vi v16, v8, 0, v0.t
647 ; CHECK-NEXT: vmax.vv v8, v8, v16, v0.t
648 ; CHECK-NEXT: addi a0, sp, 16
649 ; CHECK-NEXT: vl8r.v v16, (a0) # Unknown-size Folded Reload
650 ; CHECK-NEXT: csrr a0, vlenb
651 ; CHECK-NEXT: slli a0, a0, 4
652 ; CHECK-NEXT: add sp, sp, a0
653 ; CHECK-NEXT: addi sp, sp, 16
655 %v = call <vscale x 16 x i64> @llvm.vp.abs.nxv16i64(<vscale x 16 x i64> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
656 ret <vscale x 16 x i64> %v
659 define <vscale x 16 x i64> @vp_abs_nxv16i64_unmasked(<vscale x 16 x i64> %va, i32 zeroext %evl) {
660 ; CHECK-LABEL: vp_abs_nxv16i64_unmasked:
662 ; CHECK-NEXT: csrr a1, vlenb
663 ; CHECK-NEXT: sub a2, a0, a1
664 ; CHECK-NEXT: sltu a3, a0, a2
665 ; CHECK-NEXT: addi a3, a3, -1
666 ; CHECK-NEXT: and a2, a3, a2
667 ; CHECK-NEXT: vsetvli zero, a2, e64, m8, ta, ma
668 ; CHECK-NEXT: vrsub.vi v24, v16, 0
669 ; CHECK-NEXT: vmax.vv v16, v16, v24
670 ; CHECK-NEXT: bltu a0, a1, .LBB47_2
671 ; CHECK-NEXT: # %bb.1:
672 ; CHECK-NEXT: mv a0, a1
673 ; CHECK-NEXT: .LBB47_2:
674 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
675 ; CHECK-NEXT: vrsub.vi v24, v8, 0
676 ; CHECK-NEXT: vmax.vv v8, v8, v24
678 %head = insertelement <vscale x 16 x i1> poison, i1 true, i32 0
679 %m = shufflevector <vscale x 16 x i1> %head, <vscale x 16 x i1> poison, <vscale x 16 x i32> zeroinitializer
680 %v = call <vscale x 16 x i64> @llvm.vp.abs.nxv16i64(<vscale x 16 x i64> %va, i1 false, <vscale x 16 x i1> %m, i32 %evl)
681 ret <vscale x 16 x i64> %v