1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
6 define i32 @zext_ifpos(i32 %x) {
7 ; CHECK-LABEL: zext_ifpos:
9 ; CHECK-NEXT: mvn w8, w0
10 ; CHECK-NEXT: lsr w0, w8, #31
12 %c = icmp sgt i32 %x, -1
13 %e = zext i1 %c to i32
17 define i32 @add_zext_ifpos(i32 %x) {
18 ; CHECK-LABEL: add_zext_ifpos:
20 ; CHECK-NEXT: asr w8, w0, #31
21 ; CHECK-NEXT: add w0, w8, #42
23 %c = icmp sgt i32 %x, -1
24 %e = zext i1 %c to i32
29 define <4 x i32> @add_zext_ifpos_vec_splat(<4 x i32> %x) {
30 ; CHECK-LABEL: add_zext_ifpos_vec_splat:
32 ; CHECK-NEXT: movi v1.4s, #41
33 ; CHECK-NEXT: cmge v0.4s, v0.4s, #0
34 ; CHECK-NEXT: sub v0.4s, v1.4s, v0.4s
36 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
37 %e = zext <4 x i1> %c to <4 x i32>
38 %r = add <4 x i32> %e, <i32 41, i32 41, i32 41, i32 41>
42 define i32 @sel_ifpos_tval_bigger(i32 %x) {
43 ; CHECK-LABEL: sel_ifpos_tval_bigger:
45 ; CHECK-NEXT: mov w8, #41 // =0x29
46 ; CHECK-NEXT: cmp w0, #0
47 ; CHECK-NEXT: cinc w0, w8, ge
49 %c = icmp sgt i32 %x, -1
50 %r = select i1 %c, i32 42, i32 41
54 define i32 @sext_ifpos(i32 %x) {
55 ; CHECK-LABEL: sext_ifpos:
57 ; CHECK-NEXT: mvn w8, w0
58 ; CHECK-NEXT: asr w0, w8, #31
60 %c = icmp sgt i32 %x, -1
61 %e = sext i1 %c to i32
65 define i32 @add_sext_ifpos(i32 %x) {
66 ; CHECK-LABEL: add_sext_ifpos:
68 ; CHECK-NEXT: lsr w8, w0, #31
69 ; CHECK-NEXT: add w0, w8, #41
71 %c = icmp sgt i32 %x, -1
72 %e = sext i1 %c to i32
77 define <4 x i32> @add_sext_ifpos_vec_splat(<4 x i32> %x) {
78 ; CHECK-LABEL: add_sext_ifpos_vec_splat:
80 ; CHECK-NEXT: movi v1.4s, #42
81 ; CHECK-NEXT: cmge v0.4s, v0.4s, #0
82 ; CHECK-NEXT: add v0.4s, v0.4s, v1.4s
84 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
85 %e = sext <4 x i1> %c to <4 x i32>
86 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
90 define i32 @sel_ifpos_fval_bigger(i32 %x) {
91 ; CHECK-LABEL: sel_ifpos_fval_bigger:
93 ; CHECK-NEXT: mov w8, #41 // =0x29
94 ; CHECK-NEXT: cmp w0, #0
95 ; CHECK-NEXT: cinc w0, w8, lt
97 %c = icmp sgt i32 %x, -1
98 %r = select i1 %c, i32 41, i32 42
104 define i32 @zext_ifneg(i32 %x) {
105 ; CHECK-LABEL: zext_ifneg:
107 ; CHECK-NEXT: lsr w0, w0, #31
109 %c = icmp slt i32 %x, 0
110 %r = zext i1 %c to i32
114 define i32 @add_zext_ifneg(i32 %x) {
115 ; CHECK-LABEL: add_zext_ifneg:
117 ; CHECK-NEXT: lsr w8, w0, #31
118 ; CHECK-NEXT: add w0, w8, #41
120 %c = icmp slt i32 %x, 0
121 %e = zext i1 %c to i32
126 define i32 @sel_ifneg_tval_bigger(i32 %x) {
127 ; CHECK-LABEL: sel_ifneg_tval_bigger:
129 ; CHECK-NEXT: mov w8, #41 // =0x29
130 ; CHECK-NEXT: cmp w0, #0
131 ; CHECK-NEXT: cinc w0, w8, lt
133 %c = icmp slt i32 %x, 0
134 %r = select i1 %c, i32 42, i32 41
138 define i32 @sext_ifneg(i32 %x) {
139 ; CHECK-LABEL: sext_ifneg:
141 ; CHECK-NEXT: asr w0, w0, #31
143 %c = icmp slt i32 %x, 0
144 %r = sext i1 %c to i32
148 define i32 @add_sext_ifneg(i32 %x) {
149 ; CHECK-LABEL: add_sext_ifneg:
151 ; CHECK-NEXT: asr w8, w0, #31
152 ; CHECK-NEXT: add w0, w8, #42
154 %c = icmp slt i32 %x, 0
155 %e = sext i1 %c to i32
160 define i32 @sel_ifneg_fval_bigger(i32 %x) {
161 ; CHECK-LABEL: sel_ifneg_fval_bigger:
163 ; CHECK-NEXT: mov w8, #41 // =0x29
164 ; CHECK-NEXT: cmp w0, #0
165 ; CHECK-NEXT: cinc w0, w8, ge
167 %c = icmp slt i32 %x, 0
168 %r = select i1 %c, i32 41, i32 42
172 define i32 @add_lshr_not(i32 %x) {
173 ; CHECK-LABEL: add_lshr_not:
175 ; CHECK-NEXT: asr w8, w0, #31
176 ; CHECK-NEXT: add w0, w8, #42
178 %not = xor i32 %x, -1
179 %sh = lshr i32 %not, 31
184 define <4 x i32> @add_lshr_not_vec_splat(<4 x i32> %x) {
185 ; CHECK-LABEL: add_lshr_not_vec_splat:
187 ; CHECK-NEXT: movi v1.4s, #43
188 ; CHECK-NEXT: ssra v1.4s, v0.4s, #31
189 ; CHECK-NEXT: mov v0.16b, v1.16b
191 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
192 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
193 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
197 define i32 @sub_lshr_not(i32 %x) {
198 ; CHECK-LABEL: sub_lshr_not:
200 ; CHECK-NEXT: mov w8, #42 // =0x2a
201 ; CHECK-NEXT: bfxil w8, w0, #31, #1
202 ; CHECK-NEXT: mov w0, w8
204 %not = xor i32 %x, -1
205 %sh = lshr i32 %not, 31
210 define <4 x i32> @sub_lshr_not_vec_splat(<4 x i32> %x) {
211 ; CHECK-LABEL: sub_lshr_not_vec_splat:
213 ; CHECK-NEXT: movi v1.4s, #41
214 ; CHECK-NEXT: usra v1.4s, v0.4s, #31
215 ; CHECK-NEXT: mov v0.16b, v1.16b
217 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
218 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
219 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %e
223 define i32 @sub_lshr(i32 %x, i32 %y) {
224 ; CHECK-LABEL: sub_lshr:
226 ; CHECK-NEXT: add w0, w1, w0, asr #31
228 %sh = lshr i32 %x, 31
233 define <4 x i32> @sub_lshr_vec(<4 x i32> %x, <4 x i32> %y) {
234 ; CHECK-LABEL: sub_lshr_vec:
236 ; CHECK-NEXT: ssra v1.4s, v0.4s, #31
237 ; CHECK-NEXT: mov v0.16b, v1.16b
239 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
240 %r = sub <4 x i32> %y, %sh
244 define i32 @sub_const_op_lshr(i32 %x) {
245 ; CHECK-LABEL: sub_const_op_lshr:
247 ; CHECK-NEXT: asr w8, w0, #31
248 ; CHECK-NEXT: add w0, w8, #43
250 %sh = lshr i32 %x, 31
255 define <4 x i32> @sub_const_op_lshr_vec(<4 x i32> %x) {
256 ; CHECK-LABEL: sub_const_op_lshr_vec:
258 ; CHECK-NEXT: movi v1.4s, #42
259 ; CHECK-NEXT: ssra v1.4s, v0.4s, #31
260 ; CHECK-NEXT: mov v0.16b, v1.16b
262 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
263 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %sh