1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
6 define i32 @and_signbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
7 ; CHECK-LABEL: and_signbit_select_shl:
9 ; CHECK-NEXT: and w8, w0, #0xff0000
10 ; CHECK-NEXT: tst w1, #0x1
11 ; CHECK-NEXT: csel w8, w8, w0, ne
12 ; CHECK-NEXT: lsl w0, w8, #8
13 ; CHECK-NEXT: str w0, [x2]
15 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
16 %t1 = select i1 %cond, i32 %t0, i32 %x
18 store i32 %r, i32* %dst
21 define i32 @and_nosignbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
22 ; CHECK-LABEL: and_nosignbit_select_shl:
24 ; CHECK-NEXT: and w8, w0, #0xff0000
25 ; CHECK-NEXT: tst w1, #0x1
26 ; CHECK-NEXT: csel w8, w8, w0, ne
27 ; CHECK-NEXT: lsl w0, w8, #8
28 ; CHECK-NEXT: str w0, [x2]
30 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
31 %t1 = select i1 %cond, i32 %t0, i32 %x
33 store i32 %r, i32* %dst
37 define i32 @or_signbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
38 ; CHECK-LABEL: or_signbit_select_shl:
40 ; CHECK-NEXT: orr w8, w0, #0xff0000
41 ; CHECK-NEXT: tst w1, #0x1
42 ; CHECK-NEXT: csel w8, w8, w0, ne
43 ; CHECK-NEXT: lsl w0, w8, #8
44 ; CHECK-NEXT: str w0, [x2]
46 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
47 %t1 = select i1 %cond, i32 %t0, i32 %x
49 store i32 %r, i32* %dst
52 define i32 @or_nosignbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
53 ; CHECK-LABEL: or_nosignbit_select_shl:
55 ; CHECK-NEXT: orr w8, w0, #0xff0000
56 ; CHECK-NEXT: tst w1, #0x1
57 ; CHECK-NEXT: csel w8, w8, w0, ne
58 ; CHECK-NEXT: lsl w0, w8, #8
59 ; CHECK-NEXT: str w0, [x2]
61 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
62 %t1 = select i1 %cond, i32 %t0, i32 %x
64 store i32 %r, i32* %dst
68 define i32 @xor_signbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
69 ; CHECK-LABEL: xor_signbit_select_shl:
71 ; CHECK-NEXT: eor w8, w0, #0xff0000
72 ; CHECK-NEXT: tst w1, #0x1
73 ; CHECK-NEXT: csel w8, w8, w0, ne
74 ; CHECK-NEXT: lsl w0, w8, #8
75 ; CHECK-NEXT: str w0, [x2]
77 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
78 %t1 = select i1 %cond, i32 %t0, i32 %x
80 store i32 %r, i32* %dst
83 define i32 @xor_nosignbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
84 ; CHECK-LABEL: xor_nosignbit_select_shl:
86 ; CHECK-NEXT: eor w8, w0, #0xff0000
87 ; CHECK-NEXT: tst w1, #0x1
88 ; CHECK-NEXT: csel w8, w8, w0, ne
89 ; CHECK-NEXT: lsl w0, w8, #8
90 ; CHECK-NEXT: str w0, [x2]
92 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
93 %t1 = select i1 %cond, i32 %t0, i32 %x
95 store i32 %r, i32* %dst
99 define i32 @add_signbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
100 ; CHECK-LABEL: add_signbit_select_shl:
102 ; CHECK-NEXT: sub w8, w0, #16, lsl #12 // =65536
103 ; CHECK-NEXT: tst w1, #0x1
104 ; CHECK-NEXT: csel w8, w8, w0, ne
105 ; CHECK-NEXT: lsl w0, w8, #8
106 ; CHECK-NEXT: str w0, [x2]
108 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
109 %t1 = select i1 %cond, i32 %t0, i32 %x
111 store i32 %r, i32* %dst
114 define i32 @add_nosignbit_select_shl(i32 %x, i1 %cond, i32* %dst) {
115 ; CHECK-LABEL: add_nosignbit_select_shl:
117 ; CHECK-NEXT: mov w8, #2147418112
118 ; CHECK-NEXT: add w8, w0, w8
119 ; CHECK-NEXT: tst w1, #0x1
120 ; CHECK-NEXT: csel w8, w8, w0, ne
121 ; CHECK-NEXT: lsl w0, w8, #8
122 ; CHECK-NEXT: str w0, [x2]
124 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
125 %t1 = select i1 %cond, i32 %t0, i32 %x
127 store i32 %r, i32* %dst
131 ; logical shift right
133 define i32 @and_signbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
134 ; CHECK-LABEL: and_signbit_select_lshr:
136 ; CHECK-NEXT: and w8, w0, #0xffff0000
137 ; CHECK-NEXT: tst w1, #0x1
138 ; CHECK-NEXT: csel w8, w8, w0, ne
139 ; CHECK-NEXT: lsr w0, w8, #8
140 ; CHECK-NEXT: str w0, [x2]
142 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
143 %t1 = select i1 %cond, i32 %t0, i32 %x
145 store i32 %r, i32* %dst
148 define i32 @and_nosignbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
149 ; CHECK-LABEL: and_nosignbit_select_lshr:
151 ; CHECK-NEXT: and w8, w0, #0x7fff0000
152 ; CHECK-NEXT: tst w1, #0x1
153 ; CHECK-NEXT: csel w8, w8, w0, ne
154 ; CHECK-NEXT: lsr w0, w8, #8
155 ; CHECK-NEXT: str w0, [x2]
157 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
158 %t1 = select i1 %cond, i32 %t0, i32 %x
160 store i32 %r, i32* %dst
164 define i32 @or_signbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
165 ; CHECK-LABEL: or_signbit_select_lshr:
167 ; CHECK-NEXT: orr w8, w0, #0xffff0000
168 ; CHECK-NEXT: tst w1, #0x1
169 ; CHECK-NEXT: csel w8, w8, w0, ne
170 ; CHECK-NEXT: lsr w0, w8, #8
171 ; CHECK-NEXT: str w0, [x2]
173 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
174 %t1 = select i1 %cond, i32 %t0, i32 %x
176 store i32 %r, i32* %dst
179 define i32 @or_nosignbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
180 ; CHECK-LABEL: or_nosignbit_select_lshr:
182 ; CHECK-NEXT: orr w8, w0, #0x7fff0000
183 ; CHECK-NEXT: tst w1, #0x1
184 ; CHECK-NEXT: csel w8, w8, w0, ne
185 ; CHECK-NEXT: lsr w0, w8, #8
186 ; CHECK-NEXT: str w0, [x2]
188 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
189 %t1 = select i1 %cond, i32 %t0, i32 %x
191 store i32 %r, i32* %dst
195 define i32 @xor_signbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
196 ; CHECK-LABEL: xor_signbit_select_lshr:
198 ; CHECK-NEXT: eor w8, w0, #0xffff0000
199 ; CHECK-NEXT: tst w1, #0x1
200 ; CHECK-NEXT: csel w8, w8, w0, ne
201 ; CHECK-NEXT: lsr w0, w8, #8
202 ; CHECK-NEXT: str w0, [x2]
204 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
205 %t1 = select i1 %cond, i32 %t0, i32 %x
207 store i32 %r, i32* %dst
210 define i32 @xor_nosignbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
211 ; CHECK-LABEL: xor_nosignbit_select_lshr:
213 ; CHECK-NEXT: eor w8, w0, #0x7fff0000
214 ; CHECK-NEXT: tst w1, #0x1
215 ; CHECK-NEXT: csel w8, w8, w0, ne
216 ; CHECK-NEXT: lsr w0, w8, #8
217 ; CHECK-NEXT: str w0, [x2]
219 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
220 %t1 = select i1 %cond, i32 %t0, i32 %x
222 store i32 %r, i32* %dst
226 define i32 @add_signbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
227 ; CHECK-LABEL: add_signbit_select_lshr:
229 ; CHECK-NEXT: sub w8, w0, #16, lsl #12 // =65536
230 ; CHECK-NEXT: tst w1, #0x1
231 ; CHECK-NEXT: csel w8, w8, w0, ne
232 ; CHECK-NEXT: lsr w0, w8, #8
233 ; CHECK-NEXT: str w0, [x2]
235 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
236 %t1 = select i1 %cond, i32 %t0, i32 %x
238 store i32 %r, i32* %dst
241 define i32 @add_nosignbit_select_lshr(i32 %x, i1 %cond, i32* %dst) {
242 ; CHECK-LABEL: add_nosignbit_select_lshr:
244 ; CHECK-NEXT: mov w8, #2147418112
245 ; CHECK-NEXT: add w8, w0, w8
246 ; CHECK-NEXT: tst w1, #0x1
247 ; CHECK-NEXT: csel w8, w8, w0, ne
248 ; CHECK-NEXT: lsr w0, w8, #8
249 ; CHECK-NEXT: str w0, [x2]
251 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
252 %t1 = select i1 %cond, i32 %t0, i32 %x
254 store i32 %r, i32* %dst
258 ; arithmetic shift right
260 define i32 @and_signbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
261 ; CHECK-LABEL: and_signbit_select_ashr:
263 ; CHECK-NEXT: and w8, w0, #0xffff0000
264 ; CHECK-NEXT: tst w1, #0x1
265 ; CHECK-NEXT: csel w8, w8, w0, ne
266 ; CHECK-NEXT: asr w0, w8, #8
267 ; CHECK-NEXT: str w0, [x2]
269 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
270 %t1 = select i1 %cond, i32 %t0, i32 %x
272 store i32 %r, i32* %dst
275 define i32 @and_nosignbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
276 ; CHECK-LABEL: and_nosignbit_select_ashr:
278 ; CHECK-NEXT: and w8, w0, #0x7fff0000
279 ; CHECK-NEXT: tst w1, #0x1
280 ; CHECK-NEXT: csel w8, w8, w0, ne
281 ; CHECK-NEXT: asr w0, w8, #8
282 ; CHECK-NEXT: str w0, [x2]
284 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
285 %t1 = select i1 %cond, i32 %t0, i32 %x
287 store i32 %r, i32* %dst
291 define i32 @or_signbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
292 ; CHECK-LABEL: or_signbit_select_ashr:
294 ; CHECK-NEXT: orr w8, w0, #0xffff0000
295 ; CHECK-NEXT: tst w1, #0x1
296 ; CHECK-NEXT: csel w8, w8, w0, ne
297 ; CHECK-NEXT: asr w0, w8, #8
298 ; CHECK-NEXT: str w0, [x2]
300 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
301 %t1 = select i1 %cond, i32 %t0, i32 %x
303 store i32 %r, i32* %dst
306 define i32 @or_nosignbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
307 ; CHECK-LABEL: or_nosignbit_select_ashr:
309 ; CHECK-NEXT: orr w8, w0, #0x7fff0000
310 ; CHECK-NEXT: tst w1, #0x1
311 ; CHECK-NEXT: csel w8, w8, w0, ne
312 ; CHECK-NEXT: asr w0, w8, #8
313 ; CHECK-NEXT: str w0, [x2]
315 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
316 %t1 = select i1 %cond, i32 %t0, i32 %x
318 store i32 %r, i32* %dst
322 define i32 @xor_signbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
323 ; CHECK-LABEL: xor_signbit_select_ashr:
325 ; CHECK-NEXT: eor w8, w0, #0xffff0000
326 ; CHECK-NEXT: tst w1, #0x1
327 ; CHECK-NEXT: csel w8, w8, w0, ne
328 ; CHECK-NEXT: asr w0, w8, #8
329 ; CHECK-NEXT: str w0, [x2]
331 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
332 %t1 = select i1 %cond, i32 %t0, i32 %x
334 store i32 %r, i32* %dst
337 define i32 @xor_nosignbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
338 ; CHECK-LABEL: xor_nosignbit_select_ashr:
340 ; CHECK-NEXT: eor w8, w0, #0x7fff0000
341 ; CHECK-NEXT: tst w1, #0x1
342 ; CHECK-NEXT: csel w8, w8, w0, ne
343 ; CHECK-NEXT: asr w0, w8, #8
344 ; CHECK-NEXT: str w0, [x2]
346 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
347 %t1 = select i1 %cond, i32 %t0, i32 %x
349 store i32 %r, i32* %dst
353 define i32 @add_signbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
354 ; CHECK-LABEL: add_signbit_select_ashr:
356 ; CHECK-NEXT: sub w8, w0, #16, lsl #12 // =65536
357 ; CHECK-NEXT: tst w1, #0x1
358 ; CHECK-NEXT: csel w8, w8, w0, ne
359 ; CHECK-NEXT: asr w0, w8, #8
360 ; CHECK-NEXT: str w0, [x2]
362 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
363 %t1 = select i1 %cond, i32 %t0, i32 %x
365 store i32 %r, i32* %dst
368 define i32 @add_nosignbit_select_ashr(i32 %x, i1 %cond, i32* %dst) {
369 ; CHECK-LABEL: add_nosignbit_select_ashr:
371 ; CHECK-NEXT: mov w8, #2147418112
372 ; CHECK-NEXT: add w8, w0, w8
373 ; CHECK-NEXT: tst w1, #0x1
374 ; CHECK-NEXT: csel w8, w8, w0, ne
375 ; CHECK-NEXT: asr w0, w8, #8
376 ; CHECK-NEXT: str w0, [x2]
378 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
379 %t1 = select i1 %cond, i32 %t0, i32 %x
381 store i32 %r, i32* %dst