xref: /llvm-project/llvm/test/CodeGen/AArch64/sve2-intrinsics-while-reversed.ll (revision 62baf21daa377c4ec1a641b26931063c1117d262)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mattr=+sve2 < %s | FileCheck %s
3; RUN: llc -mattr=+sme -force-streaming < %s | FileCheck %s
4
5target triple = "aarch64-unknown-linux-gnu"
6
7;
8; WHILEGE
9;
10
11; Cannot invert the while predicate when %a is MAX_INT.
12define <vscale x 16 x i1> @whilege_b_ww(i32 %a, i32 %b) {
13; CHECK-LABEL: whilege_b_ww:
14; CHECK:       // %bb.0:
15; CHECK-NEXT:    whilele p0.b, w1, w0
16; CHECK-NEXT:    rev p0.b, p0.b
17; CHECK-NEXT:    ret
18  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilele.nxv16i1.i32(i32 %b, i32 %a)
19  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
20  ret <vscale x 16 x i1> %while.rev
21}
22
23; Cannot invert the while predicate when %a is MAX_INT.
24define <vscale x 16 x i1> @whilege_b_xx(i64 %a, i64 %b) {
25; CHECK-LABEL: whilege_b_xx:
26; CHECK:       // %bb.0:
27; CHECK-NEXT:    whilele p0.b, x1, x0
28; CHECK-NEXT:    rev p0.b, p0.b
29; CHECK-NEXT:    ret
30  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilele.nxv16i1.i64(i64 %b, i64 %a)
31  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
32  ret <vscale x 16 x i1> %while.rev
33}
34
35; Cannot invert the while predicate when %a is MAX_INT.
36define <vscale x 8 x i1> @whilege_h_ww(i32 %a, i32 %b) {
37; CHECK-LABEL: whilege_h_ww:
38; CHECK:       // %bb.0:
39; CHECK-NEXT:    whilele p0.h, w1, w0
40; CHECK-NEXT:    rev p0.h, p0.h
41; CHECK-NEXT:    ret
42  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilele.nxv8i1.i32(i32 %b, i32 %a)
43  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
44  ret <vscale x 8 x i1> %while.rev
45}
46
47; Cannot invert the while predicate when %a is MAX_INT.
48define <vscale x 8 x i1> @whilege_h_xx(i64 %a, i64 %b) {
49; CHECK-LABEL: whilege_h_xx:
50; CHECK:       // %bb.0:
51; CHECK-NEXT:    whilele p0.h, x1, x0
52; CHECK-NEXT:    rev p0.h, p0.h
53; CHECK-NEXT:    ret
54  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilele.nxv8i1.i64(i64 %b, i64 %a)
55  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
56  ret <vscale x 8 x i1> %while.rev
57}
58
59; Cannot invert the while predicate when %a is MAX_INT.
60define <vscale x 4 x i1> @whilege_s_ww(i32 %a, i32 %b) {
61; CHECK-LABEL: whilege_s_ww:
62; CHECK:       // %bb.0:
63; CHECK-NEXT:    whilele p0.s, w1, w0
64; CHECK-NEXT:    rev p0.s, p0.s
65; CHECK-NEXT:    ret
66  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilele.nxv4i1.i32(i32 %b, i32 %a)
67  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
68  ret <vscale x 4 x i1> %while.rev
69}
70
71; Cannot invert the while predicate when %a is MAX_INT.
72define <vscale x 4 x i1> @whilege_s_xx(i64 %a, i64 %b) {
73; CHECK-LABEL: whilege_s_xx:
74; CHECK:       // %bb.0:
75; CHECK-NEXT:    whilele p0.s, x1, x0
76; CHECK-NEXT:    rev p0.s, p0.s
77; CHECK-NEXT:    ret
78  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilele.nxv4i1.i64(i64 %b, i64 %a)
79  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
80  ret <vscale x 4 x i1> %while.rev
81}
82
83; Cannot invert the while predicate when %a is MAX_INT.
84define <vscale x 2 x i1> @whilege_d_ww(i32 %a, i32 %b) {
85; CHECK-LABEL: whilege_d_ww:
86; CHECK:       // %bb.0:
87; CHECK-NEXT:    whilele p0.d, w1, w0
88; CHECK-NEXT:    rev p0.d, p0.d
89; CHECK-NEXT:    ret
90  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilele.nxv2i1.i32(i32 %b, i32 %a)
91  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
92  ret <vscale x 2 x i1> %while.rev
93}
94
95; Cannot invert the while predicate when %a is MAX_INT.
96define <vscale x 2 x i1> @whilege_d_xx(i64 %a, i64 %b) {
97; CHECK-LABEL: whilege_d_xx:
98; CHECK:       // %bb.0:
99; CHECK-NEXT:    whilele p0.d, x1, x0
100; CHECK-NEXT:    rev p0.d, p0.d
101; CHECK-NEXT:    ret
102  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilele.nxv2i1.i64(i64 %b, i64 %a)
103  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
104  ret <vscale x 2 x i1> %while.rev
105}
106
107;
108; WHILEHS
109;
110
111; Cannot invert the while predicate when %a is MAX_UINT.
112define <vscale x 16 x i1> @whilehs_b_ww(i32 %a, i32 %b) {
113; CHECK-LABEL: whilehs_b_ww:
114; CHECK:       // %bb.0:
115; CHECK-NEXT:    whilels p0.b, w1, w0
116; CHECK-NEXT:    rev p0.b, p0.b
117; CHECK-NEXT:    ret
118  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilels.nxv16i1.i32(i32 %b, i32 %a)
119  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
120  ret <vscale x 16 x i1> %while.rev
121}
122
123; Cannot invert the while predicate when %a is MAX_UINT.
124define <vscale x 16 x i1> @whilehs_b_xx(i64 %a, i64 %b) {
125; CHECK-LABEL: whilehs_b_xx:
126; CHECK:       // %bb.0:
127; CHECK-NEXT:    whilels p0.b, x1, x0
128; CHECK-NEXT:    rev p0.b, p0.b
129; CHECK-NEXT:    ret
130  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilels.nxv16i1.i64(i64 %b, i64 %a)
131  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
132  ret <vscale x 16 x i1> %while.rev
133}
134
135; Cannot invert the while predicate when %a is MAX_UINT.
136define <vscale x 8 x i1> @whilehs_h_ww(i32 %a, i32 %b) {
137; CHECK-LABEL: whilehs_h_ww:
138; CHECK:       // %bb.0:
139; CHECK-NEXT:    whilels p0.h, w1, w0
140; CHECK-NEXT:    rev p0.h, p0.h
141; CHECK-NEXT:    ret
142  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilels.nxv8i1.i32(i32 %b, i32 %a)
143  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
144  ret <vscale x 8 x i1> %while.rev
145}
146
147; Cannot invert the while predicate when %a is MAX_UINT.
148define <vscale x 8 x i1> @whilehs_h_xx(i64 %a, i64 %b) {
149; CHECK-LABEL: whilehs_h_xx:
150; CHECK:       // %bb.0:
151; CHECK-NEXT:    whilels p0.h, x1, x0
152; CHECK-NEXT:    rev p0.h, p0.h
153; CHECK-NEXT:    ret
154  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilels.nxv8i1.i64(i64 %b, i64 %a)
155  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
156  ret <vscale x 8 x i1> %while.rev
157}
158
159; Cannot invert the while predicate when %a is MAX_UINT.
160define <vscale x 4 x i1> @whilehs_s_ww(i32 %a, i32 %b) {
161; CHECK-LABEL: whilehs_s_ww:
162; CHECK:       // %bb.0:
163; CHECK-NEXT:    whilels p0.s, w1, w0
164; CHECK-NEXT:    rev p0.s, p0.s
165; CHECK-NEXT:    ret
166  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilels.nxv4i1.i32(i32 %b, i32 %a)
167  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
168  ret <vscale x 4 x i1> %while.rev
169}
170
171; Cannot invert the while predicate when %a is MAX_UINT.
172define <vscale x 4 x i1> @whilehs_s_xx(i64 %a, i64 %b) {
173; CHECK-LABEL: whilehs_s_xx:
174; CHECK:       // %bb.0:
175; CHECK-NEXT:    whilels p0.s, x1, x0
176; CHECK-NEXT:    rev p0.s, p0.s
177; CHECK-NEXT:    ret
178  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilels.nxv4i1.i64(i64 %b, i64 %a)
179  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
180  ret <vscale x 4 x i1> %while.rev
181}
182
183; Cannot invert the while predicate when %a is MAX_UINT.
184define <vscale x 2 x i1> @whilehs_d_ww(i32 %a, i32 %b) {
185; CHECK-LABEL: whilehs_d_ww:
186; CHECK:       // %bb.0:
187; CHECK-NEXT:    whilels p0.d, w1, w0
188; CHECK-NEXT:    rev p0.d, p0.d
189; CHECK-NEXT:    ret
190  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilels.nxv2i1.i32(i32 %b, i32 %a)
191  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
192  ret <vscale x 2 x i1> %while.rev
193}
194
195; Cannot invert the while predicate when %a is MAX_UINT.
196define <vscale x 2 x i1> @whilehs_d_xx(i64 %a, i64 %b) {
197; CHECK-LABEL: whilehs_d_xx:
198; CHECK:       // %bb.0:
199; CHECK-NEXT:    whilels p0.d, x1, x0
200; CHECK-NEXT:    rev p0.d, p0.d
201; CHECK-NEXT:    ret
202  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilels.nxv2i1.i64(i64 %b, i64 %a)
203  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
204  ret <vscale x 2 x i1> %while.rev
205}
206
207;
208; WHILEGT
209;
210
211define <vscale x 16 x i1> @whilegt_b_ww(i32 %a, i32 %b) {
212; CHECK-LABEL: whilegt_b_ww:
213; CHECK:       // %bb.0:
214; CHECK-NEXT:    whilegt p0.b, w0, w1
215; CHECK-NEXT:    ret
216  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilelt.nxv16i1.i32(i32 %b, i32 %a)
217  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
218  ret <vscale x 16 x i1> %while.rev
219}
220
221define <vscale x 16 x i1> @whilegt_b_xx(i64 %a, i64 %b) {
222; CHECK-LABEL: whilegt_b_xx:
223; CHECK:       // %bb.0:
224; CHECK-NEXT:    whilegt p0.b, x0, x1
225; CHECK-NEXT:    ret
226  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilelt.nxv16i1.i64(i64 %b, i64 %a)
227  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
228  ret <vscale x 16 x i1> %while.rev
229}
230
231define <vscale x 8 x i1> @whilegt_h_ww(i32 %a, i32 %b) {
232; CHECK-LABEL: whilegt_h_ww:
233; CHECK:       // %bb.0:
234; CHECK-NEXT:    whilegt p0.h, w0, w1
235; CHECK-NEXT:    ret
236  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilelt.nxv8i1.i32(i32 %b, i32 %a)
237  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
238  ret <vscale x 8 x i1> %while.rev
239}
240
241define <vscale x 8 x i1> @whilegt_h_xx(i64 %a, i64 %b) {
242; CHECK-LABEL: whilegt_h_xx:
243; CHECK:       // %bb.0:
244; CHECK-NEXT:    whilegt p0.h, x0, x1
245; CHECK-NEXT:    ret
246  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilelt.nxv8i1.i64(i64 %b, i64 %a)
247  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
248  ret <vscale x 8 x i1> %while.rev
249}
250
251define <vscale x 4 x i1> @whilegt_s_ww(i32 %a, i32 %b) {
252; CHECK-LABEL: whilegt_s_ww:
253; CHECK:       // %bb.0:
254; CHECK-NEXT:    whilegt p0.s, w0, w1
255; CHECK-NEXT:    ret
256  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilelt.nxv4i1.i32(i32 %b, i32 %a)
257  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
258  ret <vscale x 4 x i1> %while.rev
259}
260
261define <vscale x 4 x i1> @whilegt_s_xx(i64 %a, i64 %b) {
262; CHECK-LABEL: whilegt_s_xx:
263; CHECK:       // %bb.0:
264; CHECK-NEXT:    whilegt p0.s, x0, x1
265; CHECK-NEXT:    ret
266  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilelt.nxv4i1.i64(i64 %b, i64 %a)
267  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
268  ret <vscale x 4 x i1> %while.rev
269}
270
271define <vscale x 2 x i1> @whilegt_d_ww(i32 %a, i32 %b) {
272; CHECK-LABEL: whilegt_d_ww:
273; CHECK:       // %bb.0:
274; CHECK-NEXT:    whilegt p0.d, w0, w1
275; CHECK-NEXT:    ret
276  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilelt.nxv2i1.i32(i32 %b, i32 %a)
277  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
278  ret <vscale x 2 x i1> %while.rev
279}
280
281define <vscale x 2 x i1> @whilegt_d_xx(i64 %a, i64 %b) {
282; CHECK-LABEL: whilegt_d_xx:
283; CHECK:       // %bb.0:
284; CHECK-NEXT:    whilegt p0.d, x0, x1
285; CHECK-NEXT:    ret
286  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilelt.nxv2i1.i64(i64 %b, i64 %a)
287  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
288  ret <vscale x 2 x i1> %while.rev
289}
290
291;
292; WHILEHI
293;
294
295define <vscale x 16 x i1> @whilehi_b_ww(i32 %a, i32 %b) {
296; CHECK-LABEL: whilehi_b_ww:
297; CHECK:       // %bb.0:
298; CHECK-NEXT:    whilehi p0.b, w0, w1
299; CHECK-NEXT:    ret
300  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilelo.nxv16i1.i32(i32 %b, i32 %a)
301  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
302  ret <vscale x 16 x i1> %while.rev
303}
304
305define <vscale x 16 x i1> @whilehi_b_xx(i64 %a, i64 %b) {
306; CHECK-LABEL: whilehi_b_xx:
307; CHECK:       // %bb.0:
308; CHECK-NEXT:    whilehi p0.b, x0, x1
309; CHECK-NEXT:    ret
310  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilelo.nxv16i1.i64(i64 %b, i64 %a)
311  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
312  ret <vscale x 16 x i1> %while.rev
313}
314
315define <vscale x 8 x i1> @whilehi_h_ww(i32 %a, i32 %b) {
316; CHECK-LABEL: whilehi_h_ww:
317; CHECK:       // %bb.0:
318; CHECK-NEXT:    whilehi p0.h, w0, w1
319; CHECK-NEXT:    ret
320  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilelo.nxv8i1.i32(i32 %b, i32 %a)
321  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
322  ret <vscale x 8 x i1> %while.rev
323}
324
325define <vscale x 8 x i1> @whilehi_h_xx(i64 %a, i64 %b) {
326; CHECK-LABEL: whilehi_h_xx:
327; CHECK:       // %bb.0:
328; CHECK-NEXT:    whilehi p0.h, x0, x1
329; CHECK-NEXT:    ret
330  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilelo.nxv8i1.i64(i64 %b, i64 %a)
331  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
332  ret <vscale x 8 x i1> %while.rev
333}
334
335define <vscale x 4 x i1> @whilehi_s_ww(i32 %a, i32 %b) {
336; CHECK-LABEL: whilehi_s_ww:
337; CHECK:       // %bb.0:
338; CHECK-NEXT:    whilehi p0.s, w0, w1
339; CHECK-NEXT:    ret
340  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilelo.nxv4i1.i32(i32 %b, i32 %a)
341  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
342  ret <vscale x 4 x i1> %while.rev
343}
344
345define <vscale x 4 x i1> @whilehi_s_xx(i64 %a, i64 %b) {
346; CHECK-LABEL: whilehi_s_xx:
347; CHECK:       // %bb.0:
348; CHECK-NEXT:    whilehi p0.s, x0, x1
349; CHECK-NEXT:    ret
350  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilelo.nxv4i1.i64(i64 %b, i64 %a)
351  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
352  ret <vscale x 4 x i1> %while.rev
353}
354
355define <vscale x 2 x i1> @whilehi_d_ww(i32 %a, i32 %b) {
356; CHECK-LABEL: whilehi_d_ww:
357; CHECK:       // %bb.0:
358; CHECK-NEXT:    whilehi p0.d, w0, w1
359; CHECK-NEXT:    ret
360  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilelo.nxv2i1.i32(i32 %b, i32 %a)
361  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
362  ret <vscale x 2 x i1> %while.rev
363}
364
365define <vscale x 2 x i1> @whilehi_d_xx(i64 %a, i64 %b) {
366; CHECK-LABEL: whilehi_d_xx:
367; CHECK:       // %bb.0:
368; CHECK-NEXT:    whilehi p0.d, x0, x1
369; CHECK-NEXT:    ret
370  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilelo.nxv2i1.i64(i64 %b, i64 %a)
371  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
372  ret <vscale x 2 x i1> %while.rev
373}
374
375;
376; WHILELE
377;
378
379; Cannot invert the while predicate when %a is MIN_INT.
380define <vscale x 16 x i1> @whilele_b_ww(i32 %a, i32 %b) {
381; CHECK-LABEL: whilele_b_ww:
382; CHECK:       // %bb.0:
383; CHECK-NEXT:    whilege p0.b, w1, w0
384; CHECK-NEXT:    rev p0.b, p0.b
385; CHECK-NEXT:    ret
386  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilege.nxv16i1.i32(i32 %b, i32 %a)
387  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
388  ret <vscale x 16 x i1> %while.rev
389}
390
391; Cannot invert the while predicate when %a is MIN_INT.
392define <vscale x 16 x i1> @whilele_b_xx(i64 %a, i64 %b) {
393; CHECK-LABEL: whilele_b_xx:
394; CHECK:       // %bb.0:
395; CHECK-NEXT:    whilege p0.b, x1, x0
396; CHECK-NEXT:    rev p0.b, p0.b
397; CHECK-NEXT:    ret
398  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilege.nxv16i1.i64(i64 %b, i64 %a)
399  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
400  ret <vscale x 16 x i1> %while.rev
401}
402
403; Cannot invert the while predicate when %a is MIN_INT.
404define <vscale x 8 x i1> @whilele_h_ww(i32 %a, i32 %b) {
405; CHECK-LABEL: whilele_h_ww:
406; CHECK:       // %bb.0:
407; CHECK-NEXT:    whilege p0.h, w1, w0
408; CHECK-NEXT:    rev p0.h, p0.h
409; CHECK-NEXT:    ret
410  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilege.nxv8i1.i32(i32 %b, i32 %a)
411  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
412  ret <vscale x 8 x i1> %while.rev
413}
414
415; Cannot invert the while predicate when %a is MIN_INT.
416define <vscale x 8 x i1> @whilele_h_xx(i64 %a, i64 %b) {
417; CHECK-LABEL: whilele_h_xx:
418; CHECK:       // %bb.0:
419; CHECK-NEXT:    whilege p0.h, x1, x0
420; CHECK-NEXT:    rev p0.h, p0.h
421; CHECK-NEXT:    ret
422  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilege.nxv8i1.i64(i64 %b, i64 %a)
423  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
424  ret <vscale x 8 x i1> %while.rev
425}
426
427; Cannot invert the while predicate when %a is MIN_INT.
428define <vscale x 4 x i1> @whilele_s_ww(i32 %a, i32 %b) {
429; CHECK-LABEL: whilele_s_ww:
430; CHECK:       // %bb.0:
431; CHECK-NEXT:    whilege p0.s, w1, w0
432; CHECK-NEXT:    rev p0.s, p0.s
433; CHECK-NEXT:    ret
434  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilege.nxv4i1.i32(i32 %b, i32 %a)
435  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
436  ret <vscale x 4 x i1> %while.rev
437}
438
439; Cannot invert the while predicate when %a is MIN_INT.
440define <vscale x 4 x i1> @whilele_s_xx(i64 %a, i64 %b) {
441; CHECK-LABEL: whilele_s_xx:
442; CHECK:       // %bb.0:
443; CHECK-NEXT:    whilege p0.s, x1, x0
444; CHECK-NEXT:    rev p0.s, p0.s
445; CHECK-NEXT:    ret
446  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilege.nxv4i1.i64(i64 %b, i64 %a)
447  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
448  ret <vscale x 4 x i1> %while.rev
449}
450
451; Cannot invert the while predicate when %a is MIN_INT.
452define <vscale x 2 x i1> @whilele_d_ww(i32 %a, i32 %b) {
453; CHECK-LABEL: whilele_d_ww:
454; CHECK:       // %bb.0:
455; CHECK-NEXT:    whilege p0.d, w1, w0
456; CHECK-NEXT:    rev p0.d, p0.d
457; CHECK-NEXT:    ret
458  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilege.nxv2i1.i32(i32 %b, i32 %a)
459  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
460  ret <vscale x 2 x i1> %while.rev
461}
462
463; Cannot invert the while predicate when %a is MIN_INT.
464define <vscale x 2 x i1> @whilele_d_xx(i64 %a, i64 %b) {
465; CHECK-LABEL: whilele_d_xx:
466; CHECK:       // %bb.0:
467; CHECK-NEXT:    whilege p0.d, x1, x0
468; CHECK-NEXT:    rev p0.d, p0.d
469; CHECK-NEXT:    ret
470  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilege.nxv2i1.i64(i64 %b, i64 %a)
471  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
472  ret <vscale x 2 x i1> %while.rev
473}
474
475;
476; WHILELO
477;
478
479define <vscale x 16 x i1> @whilelo_b_ww(i32 %a, i32 %b) {
480; CHECK-LABEL: whilelo_b_ww:
481; CHECK:       // %bb.0:
482; CHECK-NEXT:    whilelo p0.b, w0, w1
483; CHECK-NEXT:    ret
484  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilehi.nxv16i1.i32(i32 %b, i32 %a)
485  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
486  ret <vscale x 16 x i1> %while.rev
487}
488
489define <vscale x 16 x i1> @whilelo_b_xx(i64 %a, i64 %b) {
490; CHECK-LABEL: whilelo_b_xx:
491; CHECK:       // %bb.0:
492; CHECK-NEXT:    whilelo p0.b, x0, x1
493; CHECK-NEXT:    ret
494  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilehi.nxv16i1.i64(i64 %b, i64 %a)
495  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
496  ret <vscale x 16 x i1> %while.rev
497}
498
499define <vscale x 8 x i1> @whilelo_h_ww(i32 %a, i32 %b) {
500; CHECK-LABEL: whilelo_h_ww:
501; CHECK:       // %bb.0:
502; CHECK-NEXT:    whilelo p0.h, w0, w1
503; CHECK-NEXT:    ret
504  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilehi.nxv8i1.i32(i32 %b, i32 %a)
505  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
506  ret <vscale x 8 x i1> %while.rev
507}
508
509define <vscale x 8 x i1> @whilelo_h_xx(i64 %a, i64 %b) {
510; CHECK-LABEL: whilelo_h_xx:
511; CHECK:       // %bb.0:
512; CHECK-NEXT:    whilelo p0.h, x0, x1
513; CHECK-NEXT:    ret
514  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilehi.nxv8i1.i64(i64 %b, i64 %a)
515  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
516  ret <vscale x 8 x i1> %while.rev
517}
518
519define <vscale x 4 x i1> @whilelo_s_ww(i32 %a, i32 %b) {
520; CHECK-LABEL: whilelo_s_ww:
521; CHECK:       // %bb.0:
522; CHECK-NEXT:    whilelo p0.s, w0, w1
523; CHECK-NEXT:    ret
524  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilehi.nxv4i1.i32(i32 %b, i32 %a)
525  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
526  ret <vscale x 4 x i1> %while.rev
527}
528
529define <vscale x 4 x i1> @whilelo_s_xx(i64 %a, i64 %b) {
530; CHECK-LABEL: whilelo_s_xx:
531; CHECK:       // %bb.0:
532; CHECK-NEXT:    whilelo p0.s, x0, x1
533; CHECK-NEXT:    ret
534  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilehi.nxv4i1.i64(i64 %b, i64 %a)
535  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
536  ret <vscale x 4 x i1> %while.rev
537}
538
539define <vscale x 2 x i1> @whilelo_d_ww(i32 %a, i32 %b) {
540; CHECK-LABEL: whilelo_d_ww:
541; CHECK:       // %bb.0:
542; CHECK-NEXT:    whilelo p0.d, w0, w1
543; CHECK-NEXT:    ret
544  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilehi.nxv2i1.i32(i32 %b, i32 %a)
545  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
546  ret <vscale x 2 x i1> %while.rev
547}
548
549define <vscale x 2 x i1> @whilelo_d_xx(i64 %a, i64 %b) {
550; CHECK-LABEL: whilelo_d_xx:
551; CHECK:       // %bb.0:
552; CHECK-NEXT:    whilelo p0.d, x0, x1
553; CHECK-NEXT:    ret
554  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilehi.nxv2i1.i64(i64 %b, i64 %a)
555  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
556  ret <vscale x 2 x i1> %while.rev
557}
558
559;
560; WHILELS
561;
562
563; Cannot invert the while predicate when %a is MIN_UINT.
564define <vscale x 16 x i1> @whilels_b_ww(i32 %a, i32 %b) {
565; CHECK-LABEL: whilels_b_ww:
566; CHECK:       // %bb.0:
567; CHECK-NEXT:    whilehs p0.b, w1, w0
568; CHECK-NEXT:    rev p0.b, p0.b
569; CHECK-NEXT:    ret
570  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilehs.nxv16i1.i32(i32 %b, i32 %a)
571  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
572  ret <vscale x 16 x i1> %while.rev
573}
574
575; Cannot invert the while predicate when %a is MIN_UINT.
576define <vscale x 16 x i1> @whilels_b_xx(i64 %a, i64 %b) {
577; CHECK-LABEL: whilels_b_xx:
578; CHECK:       // %bb.0:
579; CHECK-NEXT:    whilehs p0.b, x1, x0
580; CHECK-NEXT:    rev p0.b, p0.b
581; CHECK-NEXT:    ret
582  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilehs.nxv16i1.i64(i64 %b, i64 %a)
583  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
584  ret <vscale x 16 x i1> %while.rev
585}
586
587; Cannot invert the while predicate when %a is MIN_UINT.
588define <vscale x 8 x i1> @whilels_h_ww(i32 %a, i32 %b) {
589; CHECK-LABEL: whilels_h_ww:
590; CHECK:       // %bb.0:
591; CHECK-NEXT:    whilehs p0.h, w1, w0
592; CHECK-NEXT:    rev p0.h, p0.h
593; CHECK-NEXT:    ret
594  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilehs.nxv8i1.i32(i32 %b, i32 %a)
595  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
596  ret <vscale x 8 x i1> %while.rev
597}
598
599; Cannot invert the while predicate when %a is MIN_UINT.
600define <vscale x 8 x i1> @whilels_h_xx(i64 %a, i64 %b) {
601; CHECK-LABEL: whilels_h_xx:
602; CHECK:       // %bb.0:
603; CHECK-NEXT:    whilehs p0.h, x1, x0
604; CHECK-NEXT:    rev p0.h, p0.h
605; CHECK-NEXT:    ret
606  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilehs.nxv8i1.i64(i64 %b, i64 %a)
607  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
608  ret <vscale x 8 x i1> %while.rev
609}
610
611; Cannot invert the while predicate when %a is MIN_UINT.
612define <vscale x 4 x i1> @whilels_s_ww(i32 %a, i32 %b) {
613; CHECK-LABEL: whilels_s_ww:
614; CHECK:       // %bb.0:
615; CHECK-NEXT:    whilehs p0.s, w1, w0
616; CHECK-NEXT:    rev p0.s, p0.s
617; CHECK-NEXT:    ret
618  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilehs.nxv4i1.i32(i32 %b, i32 %a)
619  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
620  ret <vscale x 4 x i1> %while.rev
621}
622
623; Cannot invert the while predicate when %a is MIN_UINT.
624define <vscale x 4 x i1> @whilels_s_xx(i64 %a, i64 %b) {
625; CHECK-LABEL: whilels_s_xx:
626; CHECK:       // %bb.0:
627; CHECK-NEXT:    whilehs p0.s, x1, x0
628; CHECK-NEXT:    rev p0.s, p0.s
629; CHECK-NEXT:    ret
630  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilehs.nxv4i1.i64(i64 %b, i64 %a)
631  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
632  ret <vscale x 4 x i1> %while.rev
633}
634
635; Cannot invert the while predicate when %a is MIN_UINT.
636define <vscale x 2 x i1> @whilels_d_ww(i32 %a, i32 %b) {
637; CHECK-LABEL: whilels_d_ww:
638; CHECK:       // %bb.0:
639; CHECK-NEXT:    whilehs p0.d, w1, w0
640; CHECK-NEXT:    rev p0.d, p0.d
641; CHECK-NEXT:    ret
642  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilehs.nxv2i1.i32(i32 %b, i32 %a)
643  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
644  ret <vscale x 2 x i1> %while.rev
645}
646
647; Cannot invert the while predicate when %a is MIN_UINT.
648define <vscale x 2 x i1> @whilels_d_xx(i64 %a, i64 %b) {
649; CHECK-LABEL: whilels_d_xx:
650; CHECK:       // %bb.0:
651; CHECK-NEXT:    whilehs p0.d, x1, x0
652; CHECK-NEXT:    rev p0.d, p0.d
653; CHECK-NEXT:    ret
654  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilehs.nxv2i1.i64(i64 %b, i64 %a)
655  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
656  ret <vscale x 2 x i1> %while.rev
657}
658
659;
660; WHILELT
661;
662
663define <vscale x 16 x i1> @whilelt_b_ww(i32 %a, i32 %b) {
664; CHECK-LABEL: whilelt_b_ww:
665; CHECK:       // %bb.0:
666; CHECK-NEXT:    whilelt p0.b, w0, w1
667; CHECK-NEXT:    ret
668  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilegt.nxv16i1.i32(i32 %b, i32 %a)
669  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
670  ret <vscale x 16 x i1> %while.rev
671}
672
673define <vscale x 16 x i1> @whilelt_b_xx(i64 %a, i64 %b) {
674; CHECK-LABEL: whilelt_b_xx:
675; CHECK:       // %bb.0:
676; CHECK-NEXT:    whilelt p0.b, x0, x1
677; CHECK-NEXT:    ret
678  %while = call <vscale x 16 x i1> @llvm.aarch64.sve.whilegt.nxv16i1.i64(i64 %b, i64 %a)
679  %while.rev = call <vscale x 16 x i1> @llvm.vector.reverse.nxv16i1(<vscale x 16 x i1> %while)
680  ret <vscale x 16 x i1> %while.rev
681}
682
683define <vscale x 8 x i1> @whilelt_h_ww(i32 %a, i32 %b) {
684; CHECK-LABEL: whilelt_h_ww:
685; CHECK:       // %bb.0:
686; CHECK-NEXT:    whilelt p0.h, w0, w1
687; CHECK-NEXT:    ret
688  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilegt.nxv8i1.i32(i32 %b, i32 %a)
689  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
690  ret <vscale x 8 x i1> %while.rev
691}
692
693define <vscale x 8 x i1> @whilelt_h_xx(i64 %a, i64 %b) {
694; CHECK-LABEL: whilelt_h_xx:
695; CHECK:       // %bb.0:
696; CHECK-NEXT:    whilelt p0.h, x0, x1
697; CHECK-NEXT:    ret
698  %while = call <vscale x 8 x i1> @llvm.aarch64.sve.whilegt.nxv8i1.i64(i64 %b, i64 %a)
699  %while.rev = call <vscale x 8 x i1> @llvm.vector.reverse.nxv8i1(<vscale x 8 x i1> %while)
700  ret <vscale x 8 x i1> %while.rev
701}
702
703define <vscale x 4 x i1> @whilelt_s_ww(i32 %a, i32 %b) {
704; CHECK-LABEL: whilelt_s_ww:
705; CHECK:       // %bb.0:
706; CHECK-NEXT:    whilelt p0.s, w0, w1
707; CHECK-NEXT:    ret
708  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilegt.nxv4i1.i32(i32 %b, i32 %a)
709  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
710  ret <vscale x 4 x i1> %while.rev
711}
712
713define <vscale x 4 x i1> @whilelt_s_xx(i64 %a, i64 %b) {
714; CHECK-LABEL: whilelt_s_xx:
715; CHECK:       // %bb.0:
716; CHECK-NEXT:    whilelt p0.s, x0, x1
717; CHECK-NEXT:    ret
718  %while = call <vscale x 4 x i1> @llvm.aarch64.sve.whilegt.nxv4i1.i64(i64 %b, i64 %a)
719  %while.rev = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %while)
720  ret <vscale x 4 x i1> %while.rev
721}
722
723define <vscale x 2 x i1> @whilelt_d_ww(i32 %a, i32 %b) {
724; CHECK-LABEL: whilelt_d_ww:
725; CHECK:       // %bb.0:
726; CHECK-NEXT:    whilelt p0.d, w0, w1
727; CHECK-NEXT:    ret
728  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilegt.nxv2i1.i32(i32 %b, i32 %a)
729  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
730  ret <vscale x 2 x i1> %while.rev
731}
732
733define <vscale x 2 x i1> @whilelt_d_xx(i64 %a, i64 %b) {
734; CHECK-LABEL: whilelt_d_xx:
735; CHECK:       // %bb.0:
736; CHECK-NEXT:    whilelt p0.d, x0, x1
737; CHECK-NEXT:    ret
738  %while = call <vscale x 2 x i1> @llvm.aarch64.sve.whilegt.nxv2i1.i64(i64 %b, i64 %a)
739  %while.rev = call <vscale x 2 x i1> @llvm.vector.reverse.nxv2i1(<vscale x 2 x i1> %while)
740  ret <vscale x 2 x i1> %while.rev
741}
742