1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i386-unknown-unknown | FileCheck %s --check-prefix=X32
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
5 define i32 @t1(i32 %t, i32 %val) nounwind {
8 ; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
9 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
10 ; X32-NEXT: shll %cl, %eax
15 ; X64-NEXT: movl %edi, %ecx
16 ; X64-NEXT: shll %cl, %esi
17 ; X64-NEXT: movl %esi, %eax
19 %shamt = and i32 %t, 31
20 %res = shl i32 %val, %shamt
24 define i32 @t2(i32 %t, i32 %val) nounwind {
27 ; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
28 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
29 ; X32-NEXT: shll %cl, %eax
34 ; X64-NEXT: movl %edi, %ecx
35 ; X64-NEXT: shll %cl, %esi
36 ; X64-NEXT: movl %esi, %eax
38 %shamt = and i32 %t, 63
39 %res = shl i32 %val, %shamt
43 @X = internal global i16 0
45 define void @t3(i16 %t) nounwind {
48 ; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
49 ; X32-NEXT: sarw %cl, X
54 ; X64-NEXT: movl %edi, %ecx
55 ; X64-NEXT: sarw %cl, {{.*}}(%rip)
57 %shamt = and i16 %t, 31
58 %tmp = load i16, i16* @X
59 %tmp1 = ashr i16 %tmp, %shamt
60 store i16 %tmp1, i16* @X
64 define i64 @t4(i64 %t, i64 %val) nounwind {
67 ; X32-NEXT: pushl %esi
68 ; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
69 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
70 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi
71 ; X32-NEXT: movl %esi, %edx
72 ; X32-NEXT: shrl %cl, %edx
73 ; X32-NEXT: shrdl %cl, %esi, %eax
74 ; X32-NEXT: testb $32, %cl
75 ; X32-NEXT: je .LBB3_2
77 ; X32-NEXT: movl %edx, %eax
78 ; X32-NEXT: xorl %edx, %edx
85 ; X64-NEXT: movl %edi, %ecx
86 ; X64-NEXT: shrq %cl, %rsi
87 ; X64-NEXT: movq %rsi, %rax
89 %shamt = and i64 %t, 63
90 %res = lshr i64 %val, %shamt
94 define i64 @t5(i64 %t, i64 %val) nounwind {
97 ; X32-NEXT: pushl %esi
98 ; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
99 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
100 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi
101 ; X32-NEXT: movl %esi, %edx
102 ; X32-NEXT: shrl %cl, %edx
103 ; X32-NEXT: shrdl %cl, %esi, %eax
104 ; X32-NEXT: testb $32, %cl
105 ; X32-NEXT: je .LBB4_2
107 ; X32-NEXT: movl %edx, %eax
108 ; X32-NEXT: xorl %edx, %edx
110 ; X32-NEXT: popl %esi
115 ; X64-NEXT: movl %edi, %ecx
116 ; X64-NEXT: shrq %cl, %rsi
117 ; X64-NEXT: movq %rsi, %rax
119 %shamt = and i64 %t, 191
120 %res = lshr i64 %val, %shamt
124 define void @t5ptr(i64 %t, i64* %ptr) nounwind {
127 ; X32-NEXT: pushl %edi
128 ; X32-NEXT: pushl %esi
129 ; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
130 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
131 ; X32-NEXT: movl (%eax), %edx
132 ; X32-NEXT: movl 4(%eax), %edi
133 ; X32-NEXT: movl %edi, %esi
134 ; X32-NEXT: shrl %cl, %esi
135 ; X32-NEXT: shrdl %cl, %edi, %edx
136 ; X32-NEXT: testb $32, %cl
137 ; X32-NEXT: je .LBB5_2
139 ; X32-NEXT: movl %esi, %edx
140 ; X32-NEXT: xorl %esi, %esi
142 ; X32-NEXT: movl %esi, 4(%eax)
143 ; X32-NEXT: movl %edx, (%eax)
144 ; X32-NEXT: popl %esi
145 ; X32-NEXT: popl %edi
150 ; X64-NEXT: movl %edi, %ecx
151 ; X64-NEXT: shrq %cl, (%rsi)
153 %shamt = and i64 %t, 191
154 %tmp = load i64, i64* %ptr
155 %tmp1 = lshr i64 %tmp, %shamt
156 store i64 %tmp1, i64* %ptr
162 define i64 @t6(i64 %key, i64* nocapture %val) nounwind {
165 ; X32-NEXT: pushl %edi
166 ; X32-NEXT: pushl %esi
167 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
168 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi
169 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
170 ; X32-NEXT: shrdl $3, %eax, %esi
171 ; X32-NEXT: movl %eax, %edi
172 ; X32-NEXT: shrl $3, %edi
173 ; X32-NEXT: movl (%ecx), %eax
174 ; X32-NEXT: movl 4(%ecx), %edx
175 ; X32-NEXT: addl $-1, %eax
176 ; X32-NEXT: adcl $-1, %edx
177 ; X32-NEXT: andl %esi, %eax
178 ; X32-NEXT: andl %edi, %edx
179 ; X32-NEXT: popl %esi
180 ; X32-NEXT: popl %edi
185 ; X64-NEXT: shrq $3, %rdi
186 ; X64-NEXT: movq (%rsi), %rax
187 ; X64-NEXT: decq %rax
188 ; X64-NEXT: andq %rdi, %rax
190 %shr = lshr i64 %key, 3
191 %1 = load i64, i64* %val, align 8
192 %sub = add i64 %1, 2305843009213693951
193 %and = and i64 %sub, %shr
197 define i64 @big_mask_constant(i64 %x) nounwind {
198 ; X32-LABEL: big_mask_constant:
200 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
201 ; X32-NEXT: andl $4, %eax
202 ; X32-NEXT: shll $25, %eax
203 ; X32-NEXT: xorl %edx, %edx
206 ; X64-LABEL: big_mask_constant:
208 ; X64-NEXT: shrq $7, %rdi
209 ; X64-NEXT: andl $134217728, %edi # imm = 0x8000000
210 ; X64-NEXT: movq %rdi, %rax
212 %and = and i64 %x, 17179869184 ; 0x400000000
213 %sh = lshr i64 %and, 7