1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-linux | FileCheck %s --check-prefix=32
3 ; RUN: llc < %s -mtriple=x86_64-unknown-linux | FileCheck %s --check-prefix=64
5 define i64 @rotl64(i64 %A, i8 %Amt) nounwind {
11 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
12 ; 32-NEXT: movl {{[0-9]+}}(%esp), %esi
13 ; 32-NEXT: movl {{[0-9]+}}(%esp), %edi
14 ; 32-NEXT: movl %esi, %eax
15 ; 32-NEXT: shll %cl, %eax
16 ; 32-NEXT: movl %edi, %edx
17 ; 32-NEXT: shldl %cl, %esi, %edx
18 ; 32-NEXT: testb $32, %cl
21 ; 32-NEXT: movl %eax, %edx
22 ; 32-NEXT: xorl %eax, %eax
24 ; 32-NEXT: movb $64, %ch
25 ; 32-NEXT: subb %cl, %ch
26 ; 32-NEXT: movl %edi, %ebx
27 ; 32-NEXT: movb %ch, %cl
28 ; 32-NEXT: shrl %cl, %ebx
29 ; 32-NEXT: shrdl %cl, %edi, %esi
30 ; 32-NEXT: testb $32, %ch
33 ; 32-NEXT: movl %ebx, %esi
34 ; 32-NEXT: xorl %ebx, %ebx
36 ; 32-NEXT: orl %ebx, %edx
37 ; 32-NEXT: orl %esi, %eax
45 ; 64-NEXT: movl %esi, %ecx
46 ; 64-NEXT: rolq %cl, %rdi
47 ; 64-NEXT: movq %rdi, %rax
49 %shift.upgrd.1 = zext i8 %Amt to i64
50 %B = shl i64 %A, %shift.upgrd.1
51 %Amt2 = sub i8 64, %Amt
52 %shift.upgrd.2 = zext i8 %Amt2 to i64
53 %C = lshr i64 %A, %shift.upgrd.2
58 define i64 @rotr64(i64 %A, i8 %Amt) nounwind {
64 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
65 ; 32-NEXT: movl {{[0-9]+}}(%esp), %edi
66 ; 32-NEXT: movl {{[0-9]+}}(%esp), %esi
67 ; 32-NEXT: movl %esi, %edx
68 ; 32-NEXT: shrl %cl, %edx
69 ; 32-NEXT: movl %edi, %eax
70 ; 32-NEXT: shrdl %cl, %esi, %eax
71 ; 32-NEXT: testb $32, %cl
74 ; 32-NEXT: movl %edx, %eax
75 ; 32-NEXT: xorl %edx, %edx
77 ; 32-NEXT: movb $64, %ch
78 ; 32-NEXT: subb %cl, %ch
79 ; 32-NEXT: movl %edi, %ebx
80 ; 32-NEXT: movb %ch, %cl
81 ; 32-NEXT: shll %cl, %ebx
82 ; 32-NEXT: shldl %cl, %edi, %esi
83 ; 32-NEXT: testb $32, %ch
86 ; 32-NEXT: movl %ebx, %esi
87 ; 32-NEXT: xorl %ebx, %ebx
89 ; 32-NEXT: orl %esi, %edx
90 ; 32-NEXT: orl %ebx, %eax
98 ; 64-NEXT: movl %esi, %ecx
99 ; 64-NEXT: rorq %cl, %rdi
100 ; 64-NEXT: movq %rdi, %rax
102 %shift.upgrd.3 = zext i8 %Amt to i64
103 %B = lshr i64 %A, %shift.upgrd.3
104 %Amt2 = sub i8 64, %Amt
105 %shift.upgrd.4 = zext i8 %Amt2 to i64
106 %C = shl i64 %A, %shift.upgrd.4
111 define i64 @rotli64(i64 %A) nounwind {
114 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
115 ; 32-NEXT: movl {{[0-9]+}}(%esp), %ecx
116 ; 32-NEXT: movl %ecx, %edx
117 ; 32-NEXT: shldl $5, %eax, %edx
118 ; 32-NEXT: shldl $5, %ecx, %eax
123 ; 64-NEXT: rolq $5, %rdi
124 ; 64-NEXT: movq %rdi, %rax
132 define i64 @rotri64(i64 %A) nounwind {
135 ; 32-NEXT: movl {{[0-9]+}}(%esp), %edx
136 ; 32-NEXT: movl {{[0-9]+}}(%esp), %ecx
137 ; 32-NEXT: movl %ecx, %eax
138 ; 32-NEXT: shldl $27, %edx, %eax
139 ; 32-NEXT: shldl $27, %ecx, %edx
144 ; 64-NEXT: rolq $59, %rdi
145 ; 64-NEXT: movq %rdi, %rax
153 define i64 @rotl1_64(i64 %A) nounwind {
154 ; 32-LABEL: rotl1_64:
156 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
157 ; 32-NEXT: movl {{[0-9]+}}(%esp), %ecx
158 ; 32-NEXT: movl %ecx, %edx
159 ; 32-NEXT: shldl $1, %eax, %edx
160 ; 32-NEXT: shldl $1, %ecx, %eax
163 ; 64-LABEL: rotl1_64:
166 ; 64-NEXT: movq %rdi, %rax
174 define i64 @rotr1_64(i64 %A) nounwind {
175 ; 32-LABEL: rotr1_64:
177 ; 32-NEXT: movl {{[0-9]+}}(%esp), %edx
178 ; 32-NEXT: movl {{[0-9]+}}(%esp), %ecx
179 ; 32-NEXT: movl %ecx, %eax
180 ; 32-NEXT: shldl $31, %edx, %eax
181 ; 32-NEXT: shldl $31, %ecx, %edx
184 ; 64-LABEL: rotr1_64:
187 ; 64-NEXT: movq %rdi, %rax
195 define i32 @rotl32(i32 %A, i8 %Amt) nounwind {
198 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
199 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
200 ; 32-NEXT: roll %cl, %eax
205 ; 64-NEXT: movl %esi, %ecx
206 ; 64-NEXT: roll %cl, %edi
207 ; 64-NEXT: movl %edi, %eax
209 %shift.upgrd.1 = zext i8 %Amt to i32
210 %B = shl i32 %A, %shift.upgrd.1
211 %Amt2 = sub i8 32, %Amt
212 %shift.upgrd.2 = zext i8 %Amt2 to i32
213 %C = lshr i32 %A, %shift.upgrd.2
218 define i32 @rotr32(i32 %A, i8 %Amt) nounwind {
221 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
222 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
223 ; 32-NEXT: rorl %cl, %eax
228 ; 64-NEXT: movl %esi, %ecx
229 ; 64-NEXT: rorl %cl, %edi
230 ; 64-NEXT: movl %edi, %eax
232 %shift.upgrd.3 = zext i8 %Amt to i32
233 %B = lshr i32 %A, %shift.upgrd.3
234 %Amt2 = sub i8 32, %Amt
235 %shift.upgrd.4 = zext i8 %Amt2 to i32
236 %C = shl i32 %A, %shift.upgrd.4
241 define i32 @rotli32(i32 %A) nounwind {
244 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
245 ; 32-NEXT: roll $5, %eax
250 ; 64-NEXT: roll $5, %edi
251 ; 64-NEXT: movl %edi, %eax
259 define i32 @rotri32(i32 %A) nounwind {
262 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
263 ; 32-NEXT: roll $27, %eax
268 ; 64-NEXT: roll $27, %edi
269 ; 64-NEXT: movl %edi, %eax
277 define i32 @rotl1_32(i32 %A) nounwind {
278 ; 32-LABEL: rotl1_32:
280 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
284 ; 64-LABEL: rotl1_32:
287 ; 64-NEXT: movl %edi, %eax
295 define i32 @rotr1_32(i32 %A) nounwind {
296 ; 32-LABEL: rotr1_32:
298 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
302 ; 64-LABEL: rotr1_32:
305 ; 64-NEXT: movl %edi, %eax
313 define i16 @rotl16(i16 %A, i8 %Amt) nounwind {
316 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
317 ; 32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
318 ; 32-NEXT: rolw %cl, %ax
323 ; 64-NEXT: movl %esi, %ecx
324 ; 64-NEXT: rolw %cl, %di
325 ; 64-NEXT: movl %edi, %eax
327 %shift.upgrd.5 = zext i8 %Amt to i16
328 %B = shl i16 %A, %shift.upgrd.5
329 %Amt2 = sub i8 16, %Amt
330 %shift.upgrd.6 = zext i8 %Amt2 to i16
331 %C = lshr i16 %A, %shift.upgrd.6
336 define i16 @rotr16(i16 %A, i8 %Amt) nounwind {
339 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
340 ; 32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
341 ; 32-NEXT: rorw %cl, %ax
346 ; 64-NEXT: movl %esi, %ecx
347 ; 64-NEXT: rorw %cl, %di
348 ; 64-NEXT: movl %edi, %eax
350 %shift.upgrd.7 = zext i8 %Amt to i16
351 %B = lshr i16 %A, %shift.upgrd.7
352 %Amt2 = sub i8 16, %Amt
353 %shift.upgrd.8 = zext i8 %Amt2 to i16
354 %C = shl i16 %A, %shift.upgrd.8
359 define i16 @rotli16(i16 %A) nounwind {
362 ; 32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
363 ; 32-NEXT: rolw $5, %ax
368 ; 64-NEXT: rolw $5, %di
369 ; 64-NEXT: movl %edi, %eax
377 define i16 @rotri16(i16 %A) nounwind {
380 ; 32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
381 ; 32-NEXT: rolw $11, %ax
386 ; 64-NEXT: rolw $11, %di
387 ; 64-NEXT: movl %edi, %eax
395 define i16 @rotl1_16(i16 %A) nounwind {
396 ; 32-LABEL: rotl1_16:
398 ; 32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
402 ; 64-LABEL: rotl1_16:
405 ; 64-NEXT: movl %edi, %eax
413 define i16 @rotr1_16(i16 %A) nounwind {
414 ; 32-LABEL: rotr1_16:
416 ; 32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
420 ; 64-LABEL: rotr1_16:
423 ; 64-NEXT: movl %edi, %eax
431 define i8 @rotl8(i8 %A, i8 %Amt) nounwind {
434 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
435 ; 32-NEXT: movb {{[0-9]+}}(%esp), %al
436 ; 32-NEXT: rolb %cl, %al
441 ; 64-NEXT: movl %esi, %ecx
442 ; 64-NEXT: rolb %cl, %dil
443 ; 64-NEXT: movl %edi, %eax
446 %Amt2 = sub i8 8, %Amt
447 %C = lshr i8 %A, %Amt2
452 define i8 @rotr8(i8 %A, i8 %Amt) nounwind {
455 ; 32-NEXT: movb {{[0-9]+}}(%esp), %cl
456 ; 32-NEXT: movb {{[0-9]+}}(%esp), %al
457 ; 32-NEXT: rorb %cl, %al
462 ; 64-NEXT: movl %esi, %ecx
463 ; 64-NEXT: rorb %cl, %dil
464 ; 64-NEXT: movl %edi, %eax
466 %B = lshr i8 %A, %Amt
467 %Amt2 = sub i8 8, %Amt
468 %C = shl i8 %A, %Amt2
473 define i8 @rotli8(i8 %A) nounwind {
476 ; 32-NEXT: movb {{[0-9]+}}(%esp), %al
477 ; 32-NEXT: rolb $5, %al
482 ; 64-NEXT: rolb $5, %dil
483 ; 64-NEXT: movl %edi, %eax
491 define i8 @rotri8(i8 %A) nounwind {
494 ; 32-NEXT: movb {{[0-9]+}}(%esp), %al
495 ; 32-NEXT: rolb $3, %al
500 ; 64-NEXT: rolb $3, %dil
501 ; 64-NEXT: movl %edi, %eax
509 define i8 @rotl1_8(i8 %A) nounwind {
512 ; 32-NEXT: movb {{[0-9]+}}(%esp), %al
519 ; 64-NEXT: movl %edi, %eax
527 define i8 @rotr1_8(i8 %A) nounwind {
530 ; 32-NEXT: movb {{[0-9]+}}(%esp), %al
537 ; 64-NEXT: movl %edi, %eax
545 define void @rotr1_64_mem(i64* %Aptr) nounwind {
546 ; 32-LABEL: rotr1_64_mem:
548 ; 32-NEXT: pushl %esi
549 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
550 ; 32-NEXT: movl (%eax), %ecx
551 ; 32-NEXT: movl 4(%eax), %edx
552 ; 32-NEXT: movl %edx, %esi
553 ; 32-NEXT: shldl $31, %ecx, %esi
554 ; 32-NEXT: shldl $31, %edx, %ecx
555 ; 32-NEXT: movl %ecx, 4(%eax)
556 ; 32-NEXT: movl %esi, (%eax)
560 ; 64-LABEL: rotr1_64_mem:
562 ; 64-NEXT: rorq (%rdi)
565 %A = load i64, i64 *%Aptr
569 store i64 %D, i64* %Aptr
573 define void @rotr1_32_mem(i32* %Aptr) nounwind {
574 ; 32-LABEL: rotr1_32_mem:
576 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
577 ; 32-NEXT: rorl (%eax)
580 ; 64-LABEL: rotr1_32_mem:
582 ; 64-NEXT: rorl (%rdi)
584 %A = load i32, i32 *%Aptr
588 store i32 %D, i32* %Aptr
592 define void @rotr1_16_mem(i16* %Aptr) nounwind {
593 ; 32-LABEL: rotr1_16_mem:
595 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
596 ; 32-NEXT: rorw (%eax)
599 ; 64-LABEL: rotr1_16_mem:
601 ; 64-NEXT: rorw (%rdi)
603 %A = load i16, i16 *%Aptr
607 store i16 %D, i16* %Aptr
611 define void @rotr1_8_mem(i8* %Aptr) nounwind {
612 ; 32-LABEL: rotr1_8_mem:
614 ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
615 ; 32-NEXT: rorb (%eax)
618 ; 64-LABEL: rotr1_8_mem:
620 ; 64-NEXT: rorb (%rdi)
622 %A = load i8, i8 *%Aptr
626 store i8 %D, i8* %Aptr