1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --no_x86_scrub_sp
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86
7 define i32 @and_signbit_shl(i32 %x, ptr %dst) {
8 ; X64-LABEL: and_signbit_shl:
10 ; X64-NEXT: movl %edi, %eax
11 ; X64-NEXT: shll $8, %eax
12 ; X64-NEXT: andl $-16777216, %eax # imm = 0xFF000000
13 ; X64-NEXT: movl %eax, (%rsi)
16 ; X86-LABEL: and_signbit_shl:
18 ; X86-NEXT: movl 8(%esp), %ecx
19 ; X86-NEXT: movzbl 6(%esp), %eax
20 ; X86-NEXT: shll $24, %eax
21 ; X86-NEXT: movl %eax, (%ecx)
23 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
25 store i32 %r, ptr %dst
28 define i32 @and_nosignbit_shl(i32 %x, ptr %dst) {
29 ; X64-LABEL: and_nosignbit_shl:
31 ; X64-NEXT: movl %edi, %eax
32 ; X64-NEXT: shll $8, %eax
33 ; X64-NEXT: andl $-16777216, %eax # imm = 0xFF000000
34 ; X64-NEXT: movl %eax, (%rsi)
37 ; X86-LABEL: and_nosignbit_shl:
39 ; X86-NEXT: movl 8(%esp), %ecx
40 ; X86-NEXT: movzbl 6(%esp), %eax
41 ; X86-NEXT: shll $24, %eax
42 ; X86-NEXT: movl %eax, (%ecx)
44 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
46 store i32 %r, ptr %dst
50 define i32 @or_signbit_shl(i32 %x, ptr %dst) {
51 ; X64-LABEL: or_signbit_shl:
53 ; X64-NEXT: movl %edi, %eax
54 ; X64-NEXT: shll $8, %eax
55 ; X64-NEXT: orl $-16777216, %eax # imm = 0xFF000000
56 ; X64-NEXT: movl %eax, (%rsi)
59 ; X86-LABEL: or_signbit_shl:
61 ; X86-NEXT: movl 8(%esp), %ecx
62 ; X86-NEXT: movl 4(%esp), %eax
63 ; X86-NEXT: shll $8, %eax
64 ; X86-NEXT: orl $-16777216, %eax # imm = 0xFF000000
65 ; X86-NEXT: movl %eax, (%ecx)
67 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
69 store i32 %r, ptr %dst
72 define i32 @or_nosignbit_shl(i32 %x, ptr %dst) {
73 ; X64-LABEL: or_nosignbit_shl:
75 ; X64-NEXT: movl %edi, %eax
76 ; X64-NEXT: shll $8, %eax
77 ; X64-NEXT: orl $-16777216, %eax # imm = 0xFF000000
78 ; X64-NEXT: movl %eax, (%rsi)
81 ; X86-LABEL: or_nosignbit_shl:
83 ; X86-NEXT: movl 8(%esp), %ecx
84 ; X86-NEXT: movl 4(%esp), %eax
85 ; X86-NEXT: shll $8, %eax
86 ; X86-NEXT: orl $-16777216, %eax # imm = 0xFF000000
87 ; X86-NEXT: movl %eax, (%ecx)
89 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
91 store i32 %r, ptr %dst
95 define i32 @xor_signbit_shl(i32 %x, ptr %dst) {
96 ; X64-LABEL: xor_signbit_shl:
98 ; X64-NEXT: movl %edi, %eax
99 ; X64-NEXT: shll $8, %eax
100 ; X64-NEXT: xorl $-16777216, %eax # imm = 0xFF000000
101 ; X64-NEXT: movl %eax, (%rsi)
104 ; X86-LABEL: xor_signbit_shl:
106 ; X86-NEXT: movl 8(%esp), %ecx
107 ; X86-NEXT: movl $16711680, %eax # imm = 0xFF0000
108 ; X86-NEXT: xorl 4(%esp), %eax
109 ; X86-NEXT: shll $8, %eax
110 ; X86-NEXT: movl %eax, (%ecx)
112 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
114 store i32 %r, ptr %dst
117 define i32 @xor_nosignbit_shl(i32 %x, ptr %dst) {
118 ; X64-LABEL: xor_nosignbit_shl:
120 ; X64-NEXT: movl %edi, %eax
121 ; X64-NEXT: shll $8, %eax
122 ; X64-NEXT: xorl $-16777216, %eax # imm = 0xFF000000
123 ; X64-NEXT: movl %eax, (%rsi)
126 ; X86-LABEL: xor_nosignbit_shl:
128 ; X86-NEXT: movl 8(%esp), %ecx
129 ; X86-NEXT: movl $16711680, %eax # imm = 0xFF0000
130 ; X86-NEXT: xorl 4(%esp), %eax
131 ; X86-NEXT: shll $8, %eax
132 ; X86-NEXT: movl %eax, (%ecx)
134 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
136 store i32 %r, ptr %dst
140 define i32 @add_signbit_shl(i32 %x, ptr %dst) {
141 ; X64-LABEL: add_signbit_shl:
143 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
144 ; X64-NEXT: shll $8, %edi
145 ; X64-NEXT: leal -16777216(%rdi), %eax
146 ; X64-NEXT: movl %eax, (%rsi)
149 ; X86-LABEL: add_signbit_shl:
151 ; X86-NEXT: movl 8(%esp), %ecx
152 ; X86-NEXT: movl 4(%esp), %eax
153 ; X86-NEXT: shll $8, %eax
154 ; X86-NEXT: addl $-16777216, %eax # imm = 0xFF000000
155 ; X86-NEXT: movl %eax, (%ecx)
157 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
159 store i32 %r, ptr %dst
162 define i32 @add_nosignbit_shl(i32 %x, ptr %dst) {
163 ; X64-LABEL: add_nosignbit_shl:
165 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
166 ; X64-NEXT: shll $8, %edi
167 ; X64-NEXT: leal -16777216(%rdi), %eax
168 ; X64-NEXT: movl %eax, (%rsi)
171 ; X86-LABEL: add_nosignbit_shl:
173 ; X86-NEXT: movl 8(%esp), %ecx
174 ; X86-NEXT: movl 4(%esp), %eax
175 ; X86-NEXT: shll $8, %eax
176 ; X86-NEXT: addl $-16777216, %eax # imm = 0xFF000000
177 ; X86-NEXT: movl %eax, (%ecx)
179 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
181 store i32 %r, ptr %dst
185 ; logical shift right
187 define i32 @and_signbit_lshr(i32 %x, ptr %dst) {
188 ; X64-LABEL: and_signbit_lshr:
190 ; X64-NEXT: movl %edi, %eax
191 ; X64-NEXT: shrl $8, %eax
192 ; X64-NEXT: andl $16776960, %eax # imm = 0xFFFF00
193 ; X64-NEXT: movl %eax, (%rsi)
196 ; X86-LABEL: and_signbit_lshr:
198 ; X86-NEXT: movl 8(%esp), %ecx
199 ; X86-NEXT: movzwl 6(%esp), %eax
200 ; X86-NEXT: shll $8, %eax
201 ; X86-NEXT: movl %eax, (%ecx)
203 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
205 store i32 %r, ptr %dst
208 define i32 @and_nosignbit_lshr(i32 %x, ptr %dst) {
209 ; X64-LABEL: and_nosignbit_lshr:
211 ; X64-NEXT: movl %edi, %eax
212 ; X64-NEXT: shrl $8, %eax
213 ; X64-NEXT: andl $8388352, %eax # imm = 0x7FFF00
214 ; X64-NEXT: movl %eax, (%rsi)
217 ; X86-LABEL: and_nosignbit_lshr:
219 ; X86-NEXT: movl 8(%esp), %ecx
220 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
221 ; X86-NEXT: andl 4(%esp), %eax
222 ; X86-NEXT: shrl $8, %eax
223 ; X86-NEXT: movl %eax, (%ecx)
225 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
227 store i32 %r, ptr %dst
231 define i32 @or_signbit_lshr(i32 %x, ptr %dst) {
232 ; X64-LABEL: or_signbit_lshr:
234 ; X64-NEXT: movl %edi, %eax
235 ; X64-NEXT: shrl $8, %eax
236 ; X64-NEXT: orl $16776960, %eax # imm = 0xFFFF00
237 ; X64-NEXT: movl %eax, (%rsi)
240 ; X86-LABEL: or_signbit_lshr:
242 ; X86-NEXT: movl 8(%esp), %ecx
243 ; X86-NEXT: movl $-65536, %eax # imm = 0xFFFF0000
244 ; X86-NEXT: orl 4(%esp), %eax
245 ; X86-NEXT: shrl $8, %eax
246 ; X86-NEXT: movl %eax, (%ecx)
248 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
250 store i32 %r, ptr %dst
253 define i32 @or_nosignbit_lshr(i32 %x, ptr %dst) {
254 ; X64-LABEL: or_nosignbit_lshr:
256 ; X64-NEXT: movl %edi, %eax
257 ; X64-NEXT: shrl $8, %eax
258 ; X64-NEXT: orl $8388352, %eax # imm = 0x7FFF00
259 ; X64-NEXT: movl %eax, (%rsi)
262 ; X86-LABEL: or_nosignbit_lshr:
264 ; X86-NEXT: movl 8(%esp), %ecx
265 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
266 ; X86-NEXT: orl 4(%esp), %eax
267 ; X86-NEXT: shrl $8, %eax
268 ; X86-NEXT: movl %eax, (%ecx)
270 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
272 store i32 %r, ptr %dst
276 define i32 @xor_signbit_lshr(i32 %x, ptr %dst) {
277 ; X64-LABEL: xor_signbit_lshr:
279 ; X64-NEXT: movl %edi, %eax
280 ; X64-NEXT: shrl $8, %eax
281 ; X64-NEXT: xorl $16776960, %eax # imm = 0xFFFF00
282 ; X64-NEXT: movl %eax, (%rsi)
285 ; X86-LABEL: xor_signbit_lshr:
287 ; X86-NEXT: movl 8(%esp), %ecx
288 ; X86-NEXT: movl $-65536, %eax # imm = 0xFFFF0000
289 ; X86-NEXT: xorl 4(%esp), %eax
290 ; X86-NEXT: shrl $8, %eax
291 ; X86-NEXT: movl %eax, (%ecx)
293 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
295 store i32 %r, ptr %dst
298 define i32 @xor_nosignbit_lshr(i32 %x, ptr %dst) {
299 ; X64-LABEL: xor_nosignbit_lshr:
301 ; X64-NEXT: movl %edi, %eax
302 ; X64-NEXT: shrl $8, %eax
303 ; X64-NEXT: xorl $8388352, %eax # imm = 0x7FFF00
304 ; X64-NEXT: movl %eax, (%rsi)
307 ; X86-LABEL: xor_nosignbit_lshr:
309 ; X86-NEXT: movl 8(%esp), %ecx
310 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
311 ; X86-NEXT: xorl 4(%esp), %eax
312 ; X86-NEXT: shrl $8, %eax
313 ; X86-NEXT: movl %eax, (%ecx)
315 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
317 store i32 %r, ptr %dst
321 define i32 @add_signbit_lshr(i32 %x, ptr %dst) {
322 ; X64-LABEL: add_signbit_lshr:
324 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
325 ; X64-NEXT: leal -65536(%rdi), %eax
326 ; X64-NEXT: shrl $8, %eax
327 ; X64-NEXT: movl %eax, (%rsi)
330 ; X86-LABEL: add_signbit_lshr:
332 ; X86-NEXT: movl 8(%esp), %ecx
333 ; X86-NEXT: movl $-65536, %eax # imm = 0xFFFF0000
334 ; X86-NEXT: addl 4(%esp), %eax
335 ; X86-NEXT: shrl $8, %eax
336 ; X86-NEXT: movl %eax, (%ecx)
338 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
340 store i32 %r, ptr %dst
343 define i32 @add_nosignbit_lshr(i32 %x, ptr %dst) {
344 ; X64-LABEL: add_nosignbit_lshr:
346 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
347 ; X64-NEXT: leal 2147418112(%rdi), %eax
348 ; X64-NEXT: shrl $8, %eax
349 ; X64-NEXT: movl %eax, (%rsi)
352 ; X86-LABEL: add_nosignbit_lshr:
354 ; X86-NEXT: movl 8(%esp), %ecx
355 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
356 ; X86-NEXT: addl 4(%esp), %eax
357 ; X86-NEXT: shrl $8, %eax
358 ; X86-NEXT: movl %eax, (%ecx)
360 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
362 store i32 %r, ptr %dst
366 ; arithmetic shift right
368 define i32 @and_signbit_ashr(i32 %x, ptr %dst) {
369 ; X64-LABEL: and_signbit_ashr:
371 ; X64-NEXT: movl %edi, %eax
372 ; X64-NEXT: sarl $8, %eax
373 ; X64-NEXT: andl $-256, %eax
374 ; X64-NEXT: movl %eax, (%rsi)
377 ; X86-LABEL: and_signbit_ashr:
379 ; X86-NEXT: movl 8(%esp), %ecx
380 ; X86-NEXT: movswl 6(%esp), %eax
381 ; X86-NEXT: shll $8, %eax
382 ; X86-NEXT: movl %eax, (%ecx)
384 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
386 store i32 %r, ptr %dst
389 define i32 @and_nosignbit_ashr(i32 %x, ptr %dst) {
390 ; X64-LABEL: and_nosignbit_ashr:
392 ; X64-NEXT: movl %edi, %eax
393 ; X64-NEXT: shrl $8, %eax
394 ; X64-NEXT: andl $8388352, %eax # imm = 0x7FFF00
395 ; X64-NEXT: movl %eax, (%rsi)
398 ; X86-LABEL: and_nosignbit_ashr:
400 ; X86-NEXT: movl 8(%esp), %ecx
401 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
402 ; X86-NEXT: andl 4(%esp), %eax
403 ; X86-NEXT: shrl $8, %eax
404 ; X86-NEXT: movl %eax, (%ecx)
406 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
408 store i32 %r, ptr %dst
412 define i32 @or_signbit_ashr(i32 %x, ptr %dst) {
413 ; X64-LABEL: or_signbit_ashr:
415 ; X64-NEXT: movl %edi, %eax
416 ; X64-NEXT: shrl $8, %eax
417 ; X64-NEXT: orl $-256, %eax
418 ; X64-NEXT: movl %eax, (%rsi)
421 ; X86-LABEL: or_signbit_ashr:
423 ; X86-NEXT: movl 8(%esp), %ecx
424 ; X86-NEXT: movl $-65536, %eax # imm = 0xFFFF0000
425 ; X86-NEXT: orl 4(%esp), %eax
426 ; X86-NEXT: sarl $8, %eax
427 ; X86-NEXT: movl %eax, (%ecx)
429 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
431 store i32 %r, ptr %dst
434 define i32 @or_nosignbit_ashr(i32 %x, ptr %dst) {
435 ; X64-LABEL: or_nosignbit_ashr:
437 ; X64-NEXT: movl %edi, %eax
438 ; X64-NEXT: sarl $8, %eax
439 ; X64-NEXT: orl $8388352, %eax # imm = 0x7FFF00
440 ; X64-NEXT: movl %eax, (%rsi)
443 ; X86-LABEL: or_nosignbit_ashr:
445 ; X86-NEXT: movl 8(%esp), %ecx
446 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
447 ; X86-NEXT: orl 4(%esp), %eax
448 ; X86-NEXT: sarl $8, %eax
449 ; X86-NEXT: movl %eax, (%ecx)
451 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
453 store i32 %r, ptr %dst
457 define i32 @xor_signbit_ashr(i32 %x, ptr %dst) {
458 ; X64-LABEL: xor_signbit_ashr:
460 ; X64-NEXT: movl %edi, %eax
461 ; X64-NEXT: sarl $8, %eax
462 ; X64-NEXT: xorl $-256, %eax
463 ; X64-NEXT: movl %eax, (%rsi)
466 ; X86-LABEL: xor_signbit_ashr:
468 ; X86-NEXT: movl 8(%esp), %ecx
469 ; X86-NEXT: movl $-65536, %eax # imm = 0xFFFF0000
470 ; X86-NEXT: xorl 4(%esp), %eax
471 ; X86-NEXT: sarl $8, %eax
472 ; X86-NEXT: movl %eax, (%ecx)
474 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
476 store i32 %r, ptr %dst
479 define i32 @xor_nosignbit_ashr(i32 %x, ptr %dst) {
480 ; X64-LABEL: xor_nosignbit_ashr:
482 ; X64-NEXT: movl %edi, %eax
483 ; X64-NEXT: sarl $8, %eax
484 ; X64-NEXT: xorl $8388352, %eax # imm = 0x7FFF00
485 ; X64-NEXT: movl %eax, (%rsi)
488 ; X86-LABEL: xor_nosignbit_ashr:
490 ; X86-NEXT: movl 8(%esp), %ecx
491 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
492 ; X86-NEXT: xorl 4(%esp), %eax
493 ; X86-NEXT: sarl $8, %eax
494 ; X86-NEXT: movl %eax, (%ecx)
496 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
498 store i32 %r, ptr %dst
502 define i32 @add_signbit_ashr(i32 %x, ptr %dst) {
503 ; X64-LABEL: add_signbit_ashr:
505 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
506 ; X64-NEXT: leal -65536(%rdi), %eax
507 ; X64-NEXT: sarl $8, %eax
508 ; X64-NEXT: movl %eax, (%rsi)
511 ; X86-LABEL: add_signbit_ashr:
513 ; X86-NEXT: movl 8(%esp), %ecx
514 ; X86-NEXT: movl $-65536, %eax # imm = 0xFFFF0000
515 ; X86-NEXT: addl 4(%esp), %eax
516 ; X86-NEXT: sarl $8, %eax
517 ; X86-NEXT: movl %eax, (%ecx)
519 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
521 store i32 %r, ptr %dst
524 define i32 @add_nosignbit_ashr(i32 %x, ptr %dst) {
525 ; X64-LABEL: add_nosignbit_ashr:
527 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
528 ; X64-NEXT: leal 2147418112(%rdi), %eax
529 ; X64-NEXT: sarl $8, %eax
530 ; X64-NEXT: movl %eax, (%rsi)
533 ; X86-LABEL: add_nosignbit_ashr:
535 ; X86-NEXT: movl 8(%esp), %ecx
536 ; X86-NEXT: movl $2147418112, %eax # imm = 0x7FFF0000
537 ; X86-NEXT: addl 4(%esp), %eax
538 ; X86-NEXT: sarl $8, %eax
539 ; X86-NEXT: movl %eax, (%ecx)
541 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
543 store i32 %r, ptr %dst