1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
3 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
4 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
5 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X86-BMI2
6 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X86-BMI2
7 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=-bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X64-NOBMI2
8 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X64-NOBMI2
9 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X64-NOBMI2
10 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X64-BMI2
11 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X64-BMI2
15 define i64 @sub63_shiftl64(i64 %val, i64 %cnt) nounwind {
16 ; X86-NOBMI2-LABEL: sub63_shiftl64:
17 ; X86-NOBMI2: # %bb.0:
18 ; X86-NOBMI2-NEXT: pushl %esi
19 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
20 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
21 ; X86-NOBMI2-NEXT: movb $63, %cl
22 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
23 ; X86-NOBMI2-NEXT: movl %esi, %eax
24 ; X86-NOBMI2-NEXT: shll %cl, %eax
25 ; X86-NOBMI2-NEXT: shldl %cl, %esi, %edx
26 ; X86-NOBMI2-NEXT: testb $32, %cl
27 ; X86-NOBMI2-NEXT: je .LBB0_2
28 ; X86-NOBMI2-NEXT: # %bb.1:
29 ; X86-NOBMI2-NEXT: movl %eax, %edx
30 ; X86-NOBMI2-NEXT: xorl %eax, %eax
31 ; X86-NOBMI2-NEXT: .LBB0_2:
32 ; X86-NOBMI2-NEXT: popl %esi
33 ; X86-NOBMI2-NEXT: retl
35 ; X86-BMI2-LABEL: sub63_shiftl64:
37 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
38 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
39 ; X86-BMI2-NEXT: movb $63, %cl
40 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
41 ; X86-BMI2-NEXT: shldl %cl, %eax, %edx
42 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
43 ; X86-BMI2-NEXT: testb $32, %cl
44 ; X86-BMI2-NEXT: je .LBB0_2
45 ; X86-BMI2-NEXT: # %bb.1:
46 ; X86-BMI2-NEXT: movl %eax, %edx
47 ; X86-BMI2-NEXT: xorl %eax, %eax
48 ; X86-BMI2-NEXT: .LBB0_2:
51 ; X64-NOBMI2-LABEL: sub63_shiftl64:
52 ; X64-NOBMI2: # %bb.0:
53 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
54 ; X64-NOBMI2-NEXT: movq %rdi, %rax
55 ; X64-NOBMI2-NEXT: notb %cl
56 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
57 ; X64-NOBMI2-NEXT: shlq %cl, %rax
58 ; X64-NOBMI2-NEXT: retq
60 ; X64-BMI2-LABEL: sub63_shiftl64:
62 ; X64-BMI2-NEXT: notb %sil
63 ; X64-BMI2-NEXT: shlxq %rsi, %rdi, %rax
65 %adjcnt = sub i64 63, %cnt
66 %result = shl i64 %val, %adjcnt
70 define i64 @xor63_shiftr64(i64 %val, i64 %cnt) nounwind {
71 ; X86-NOBMI2-LABEL: xor63_shiftr64:
72 ; X86-NOBMI2: # %bb.0:
73 ; X86-NOBMI2-NEXT: pushl %esi
74 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
75 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
76 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
77 ; X86-NOBMI2-NEXT: xorb $63, %cl
78 ; X86-NOBMI2-NEXT: movl %esi, %edx
79 ; X86-NOBMI2-NEXT: shrl %cl, %edx
80 ; X86-NOBMI2-NEXT: shrdl %cl, %esi, %eax
81 ; X86-NOBMI2-NEXT: testb $32, %cl
82 ; X86-NOBMI2-NEXT: je .LBB1_2
83 ; X86-NOBMI2-NEXT: # %bb.1:
84 ; X86-NOBMI2-NEXT: movl %edx, %eax
85 ; X86-NOBMI2-NEXT: xorl %edx, %edx
86 ; X86-NOBMI2-NEXT: .LBB1_2:
87 ; X86-NOBMI2-NEXT: popl %esi
88 ; X86-NOBMI2-NEXT: retl
90 ; X86-BMI2-LABEL: xor63_shiftr64:
92 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
93 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
94 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
95 ; X86-BMI2-NEXT: xorb $63, %cl
96 ; X86-BMI2-NEXT: shrdl %cl, %edx, %eax
97 ; X86-BMI2-NEXT: shrxl %ecx, %edx, %edx
98 ; X86-BMI2-NEXT: testb $32, %cl
99 ; X86-BMI2-NEXT: je .LBB1_2
100 ; X86-BMI2-NEXT: # %bb.1:
101 ; X86-BMI2-NEXT: movl %edx, %eax
102 ; X86-BMI2-NEXT: xorl %edx, %edx
103 ; X86-BMI2-NEXT: .LBB1_2:
104 ; X86-BMI2-NEXT: retl
106 ; X64-NOBMI2-LABEL: xor63_shiftr64:
107 ; X64-NOBMI2: # %bb.0:
108 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
109 ; X64-NOBMI2-NEXT: movq %rdi, %rax
110 ; X64-NOBMI2-NEXT: notb %cl
111 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
112 ; X64-NOBMI2-NEXT: shrq %cl, %rax
113 ; X64-NOBMI2-NEXT: retq
115 ; X64-BMI2-LABEL: xor63_shiftr64:
117 ; X64-BMI2-NEXT: notb %sil
118 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
119 ; X64-BMI2-NEXT: retq
120 %adjcnt = xor i64 %cnt, 63
121 %result = lshr i64 %val, %adjcnt
125 define i64 @sub127_shiftl64(i64 %val, i64 %cnt) nounwind {
126 ; X86-NOBMI2-LABEL: sub127_shiftl64:
127 ; X86-NOBMI2: # %bb.0:
128 ; X86-NOBMI2-NEXT: pushl %esi
129 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
130 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
131 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
132 ; X86-NOBMI2-NEXT: xorb $127, %cl
133 ; X86-NOBMI2-NEXT: movl %esi, %eax
134 ; X86-NOBMI2-NEXT: shll %cl, %eax
135 ; X86-NOBMI2-NEXT: shldl %cl, %esi, %edx
136 ; X86-NOBMI2-NEXT: testb $32, %cl
137 ; X86-NOBMI2-NEXT: je .LBB2_2
138 ; X86-NOBMI2-NEXT: # %bb.1:
139 ; X86-NOBMI2-NEXT: movl %eax, %edx
140 ; X86-NOBMI2-NEXT: xorl %eax, %eax
141 ; X86-NOBMI2-NEXT: .LBB2_2:
142 ; X86-NOBMI2-NEXT: popl %esi
143 ; X86-NOBMI2-NEXT: retl
145 ; X86-BMI2-LABEL: sub127_shiftl64:
147 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
148 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
149 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
150 ; X86-BMI2-NEXT: xorb $127, %cl
151 ; X86-BMI2-NEXT: shldl %cl, %eax, %edx
152 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
153 ; X86-BMI2-NEXT: testb $32, %cl
154 ; X86-BMI2-NEXT: je .LBB2_2
155 ; X86-BMI2-NEXT: # %bb.1:
156 ; X86-BMI2-NEXT: movl %eax, %edx
157 ; X86-BMI2-NEXT: xorl %eax, %eax
158 ; X86-BMI2-NEXT: .LBB2_2:
159 ; X86-BMI2-NEXT: retl
161 ; X64-NOBMI2-LABEL: sub127_shiftl64:
162 ; X64-NOBMI2: # %bb.0:
163 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
164 ; X64-NOBMI2-NEXT: movq %rdi, %rax
165 ; X64-NOBMI2-NEXT: notb %cl
166 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
167 ; X64-NOBMI2-NEXT: shlq %cl, %rax
168 ; X64-NOBMI2-NEXT: retq
170 ; X64-BMI2-LABEL: sub127_shiftl64:
172 ; X64-BMI2-NEXT: notb %sil
173 ; X64-BMI2-NEXT: shlxq %rsi, %rdi, %rax
174 ; X64-BMI2-NEXT: retq
175 %adjcnt = sub i64 127, %cnt
176 %result = shl i64 %val, %adjcnt
180 define i64 @xor127_shiftr64(i64 %val, i64 %cnt) nounwind {
181 ; X86-NOBMI2-LABEL: xor127_shiftr64:
182 ; X86-NOBMI2: # %bb.0:
183 ; X86-NOBMI2-NEXT: pushl %esi
184 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
185 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
186 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
187 ; X86-NOBMI2-NEXT: xorb $127, %cl
188 ; X86-NOBMI2-NEXT: movl %esi, %edx
189 ; X86-NOBMI2-NEXT: shrl %cl, %edx
190 ; X86-NOBMI2-NEXT: shrdl %cl, %esi, %eax
191 ; X86-NOBMI2-NEXT: testb $32, %cl
192 ; X86-NOBMI2-NEXT: je .LBB3_2
193 ; X86-NOBMI2-NEXT: # %bb.1:
194 ; X86-NOBMI2-NEXT: movl %edx, %eax
195 ; X86-NOBMI2-NEXT: xorl %edx, %edx
196 ; X86-NOBMI2-NEXT: .LBB3_2:
197 ; X86-NOBMI2-NEXT: popl %esi
198 ; X86-NOBMI2-NEXT: retl
200 ; X86-BMI2-LABEL: xor127_shiftr64:
202 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
203 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
204 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
205 ; X86-BMI2-NEXT: xorb $127, %cl
206 ; X86-BMI2-NEXT: shrdl %cl, %edx, %eax
207 ; X86-BMI2-NEXT: shrxl %ecx, %edx, %edx
208 ; X86-BMI2-NEXT: testb $32, %cl
209 ; X86-BMI2-NEXT: je .LBB3_2
210 ; X86-BMI2-NEXT: # %bb.1:
211 ; X86-BMI2-NEXT: movl %edx, %eax
212 ; X86-BMI2-NEXT: xorl %edx, %edx
213 ; X86-BMI2-NEXT: .LBB3_2:
214 ; X86-BMI2-NEXT: retl
216 ; X64-NOBMI2-LABEL: xor127_shiftr64:
217 ; X64-NOBMI2: # %bb.0:
218 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
219 ; X64-NOBMI2-NEXT: movq %rdi, %rax
220 ; X64-NOBMI2-NEXT: notb %cl
221 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
222 ; X64-NOBMI2-NEXT: shrq %cl, %rax
223 ; X64-NOBMI2-NEXT: retq
225 ; X64-BMI2-LABEL: xor127_shiftr64:
227 ; X64-BMI2-NEXT: notb %sil
228 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
229 ; X64-BMI2-NEXT: retq
230 %adjcnt = xor i64 %cnt, 127
231 %result = lshr i64 %val, %adjcnt
235 define i64 @xor64_shiftl64(i64 %val, i64 %cnt) nounwind {
236 ; X86-NOBMI2-LABEL: xor64_shiftl64:
237 ; X86-NOBMI2: # %bb.0:
238 ; X86-NOBMI2-NEXT: pushl %esi
239 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
240 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
241 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
242 ; X86-NOBMI2-NEXT: xorb $64, %cl
243 ; X86-NOBMI2-NEXT: movl %esi, %eax
244 ; X86-NOBMI2-NEXT: shll %cl, %eax
245 ; X86-NOBMI2-NEXT: shldl %cl, %esi, %edx
246 ; X86-NOBMI2-NEXT: testb $32, %cl
247 ; X86-NOBMI2-NEXT: je .LBB4_2
248 ; X86-NOBMI2-NEXT: # %bb.1:
249 ; X86-NOBMI2-NEXT: movl %eax, %edx
250 ; X86-NOBMI2-NEXT: xorl %eax, %eax
251 ; X86-NOBMI2-NEXT: .LBB4_2:
252 ; X86-NOBMI2-NEXT: popl %esi
253 ; X86-NOBMI2-NEXT: retl
255 ; X86-BMI2-LABEL: xor64_shiftl64:
257 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
258 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
259 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
260 ; X86-BMI2-NEXT: xorb $64, %cl
261 ; X86-BMI2-NEXT: shldl %cl, %eax, %edx
262 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
263 ; X86-BMI2-NEXT: testb $32, %cl
264 ; X86-BMI2-NEXT: je .LBB4_2
265 ; X86-BMI2-NEXT: # %bb.1:
266 ; X86-BMI2-NEXT: movl %eax, %edx
267 ; X86-BMI2-NEXT: xorl %eax, %eax
268 ; X86-BMI2-NEXT: .LBB4_2:
269 ; X86-BMI2-NEXT: retl
271 ; X64-NOBMI2-LABEL: xor64_shiftl64:
272 ; X64-NOBMI2: # %bb.0:
273 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
274 ; X64-NOBMI2-NEXT: movq %rdi, %rax
275 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
276 ; X64-NOBMI2-NEXT: shlq %cl, %rax
277 ; X64-NOBMI2-NEXT: retq
279 ; X64-BMI2-LABEL: xor64_shiftl64:
281 ; X64-BMI2-NEXT: shlxq %rsi, %rdi, %rax
282 ; X64-BMI2-NEXT: retq
283 %adjcnt = xor i64 %cnt, 64
284 %result = shl i64 %val, %adjcnt
288 define i64 @sub1s_shiftr64(i64 %val, i64 %cnt) nounwind {
289 ; X86-NOBMI2-LABEL: sub1s_shiftr64:
290 ; X86-NOBMI2: # %bb.0:
291 ; X86-NOBMI2-NEXT: pushl %esi
292 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
293 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
294 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
295 ; X86-NOBMI2-NEXT: notb %cl
296 ; X86-NOBMI2-NEXT: movl %esi, %edx
297 ; X86-NOBMI2-NEXT: shrl %cl, %edx
298 ; X86-NOBMI2-NEXT: shrdl %cl, %esi, %eax
299 ; X86-NOBMI2-NEXT: testb $32, %cl
300 ; X86-NOBMI2-NEXT: je .LBB5_2
301 ; X86-NOBMI2-NEXT: # %bb.1:
302 ; X86-NOBMI2-NEXT: movl %edx, %eax
303 ; X86-NOBMI2-NEXT: xorl %edx, %edx
304 ; X86-NOBMI2-NEXT: .LBB5_2:
305 ; X86-NOBMI2-NEXT: popl %esi
306 ; X86-NOBMI2-NEXT: retl
308 ; X86-BMI2-LABEL: sub1s_shiftr64:
310 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
311 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
312 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
313 ; X86-BMI2-NEXT: notb %cl
314 ; X86-BMI2-NEXT: shrdl %cl, %edx, %eax
315 ; X86-BMI2-NEXT: shrxl %ecx, %edx, %edx
316 ; X86-BMI2-NEXT: testb $32, %cl
317 ; X86-BMI2-NEXT: je .LBB5_2
318 ; X86-BMI2-NEXT: # %bb.1:
319 ; X86-BMI2-NEXT: movl %edx, %eax
320 ; X86-BMI2-NEXT: xorl %edx, %edx
321 ; X86-BMI2-NEXT: .LBB5_2:
322 ; X86-BMI2-NEXT: retl
324 ; X64-NOBMI2-LABEL: sub1s_shiftr64:
325 ; X64-NOBMI2: # %bb.0:
326 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
327 ; X64-NOBMI2-NEXT: movq %rdi, %rax
328 ; X64-NOBMI2-NEXT: notb %cl
329 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
330 ; X64-NOBMI2-NEXT: shrq %cl, %rax
331 ; X64-NOBMI2-NEXT: retq
333 ; X64-BMI2-LABEL: sub1s_shiftr64:
335 ; X64-BMI2-NEXT: notb %sil
336 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
337 ; X64-BMI2-NEXT: retq
338 %adjcnt = xor i64 %cnt, -1
339 %result = lshr i64 %val, %adjcnt
343 define i64 @xor1s_shiftl64(i64 %val, i64 %cnt) nounwind {
344 ; X86-NOBMI2-LABEL: xor1s_shiftl64:
345 ; X86-NOBMI2: # %bb.0:
346 ; X86-NOBMI2-NEXT: pushl %esi
347 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
348 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
349 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
350 ; X86-NOBMI2-NEXT: notb %cl
351 ; X86-NOBMI2-NEXT: movl %esi, %eax
352 ; X86-NOBMI2-NEXT: shll %cl, %eax
353 ; X86-NOBMI2-NEXT: shldl %cl, %esi, %edx
354 ; X86-NOBMI2-NEXT: testb $32, %cl
355 ; X86-NOBMI2-NEXT: je .LBB6_2
356 ; X86-NOBMI2-NEXT: # %bb.1:
357 ; X86-NOBMI2-NEXT: movl %eax, %edx
358 ; X86-NOBMI2-NEXT: xorl %eax, %eax
359 ; X86-NOBMI2-NEXT: .LBB6_2:
360 ; X86-NOBMI2-NEXT: popl %esi
361 ; X86-NOBMI2-NEXT: retl
363 ; X86-BMI2-LABEL: xor1s_shiftl64:
365 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
366 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
367 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
368 ; X86-BMI2-NEXT: notb %cl
369 ; X86-BMI2-NEXT: shldl %cl, %eax, %edx
370 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
371 ; X86-BMI2-NEXT: testb $32, %cl
372 ; X86-BMI2-NEXT: je .LBB6_2
373 ; X86-BMI2-NEXT: # %bb.1:
374 ; X86-BMI2-NEXT: movl %eax, %edx
375 ; X86-BMI2-NEXT: xorl %eax, %eax
376 ; X86-BMI2-NEXT: .LBB6_2:
377 ; X86-BMI2-NEXT: retl
379 ; X64-NOBMI2-LABEL: xor1s_shiftl64:
380 ; X64-NOBMI2: # %bb.0:
381 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
382 ; X64-NOBMI2-NEXT: movq %rdi, %rax
383 ; X64-NOBMI2-NEXT: notb %cl
384 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
385 ; X64-NOBMI2-NEXT: shlq %cl, %rax
386 ; X64-NOBMI2-NEXT: retq
388 ; X64-BMI2-LABEL: xor1s_shiftl64:
390 ; X64-BMI2-NEXT: notb %sil
391 ; X64-BMI2-NEXT: shlxq %rsi, %rdi, %rax
392 ; X64-BMI2-NEXT: retq
393 %adjcnt = xor i64 %cnt, -1
394 %result = shl i64 %val, %adjcnt
398 define i32 @sub31_shiftr32(i32 %val, i32 %cnt) nounwind {
399 ; X86-NOBMI2-LABEL: sub31_shiftr32:
400 ; X86-NOBMI2: # %bb.0:
401 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
402 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
403 ; X86-NOBMI2-NEXT: notb %cl
404 ; X86-NOBMI2-NEXT: shrl %cl, %eax
405 ; X86-NOBMI2-NEXT: retl
407 ; X86-BMI2-LABEL: sub31_shiftr32:
409 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
410 ; X86-BMI2-NEXT: notb %al
411 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %eax
412 ; X86-BMI2-NEXT: retl
414 ; X64-NOBMI2-LABEL: sub31_shiftr32:
415 ; X64-NOBMI2: # %bb.0:
416 ; X64-NOBMI2-NEXT: movl %esi, %ecx
417 ; X64-NOBMI2-NEXT: movl %edi, %eax
418 ; X64-NOBMI2-NEXT: notb %cl
419 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
420 ; X64-NOBMI2-NEXT: shrl %cl, %eax
421 ; X64-NOBMI2-NEXT: retq
423 ; X64-BMI2-LABEL: sub31_shiftr32:
425 ; X64-BMI2-NEXT: notb %sil
426 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
427 ; X64-BMI2-NEXT: retq
428 %adjcnt = sub i32 31, %cnt
429 %result = lshr i32 %val, %adjcnt
433 define i32 @xor31_shiftl32(i32 %val, i32 %cnt) nounwind {
434 ; X86-NOBMI2-LABEL: xor31_shiftl32:
435 ; X86-NOBMI2: # %bb.0:
436 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
437 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
438 ; X86-NOBMI2-NEXT: notb %cl
439 ; X86-NOBMI2-NEXT: shll %cl, %eax
440 ; X86-NOBMI2-NEXT: retl
442 ; X86-BMI2-LABEL: xor31_shiftl32:
444 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
445 ; X86-BMI2-NEXT: notb %al
446 ; X86-BMI2-NEXT: shlxl %eax, {{[0-9]+}}(%esp), %eax
447 ; X86-BMI2-NEXT: retl
449 ; X64-NOBMI2-LABEL: xor31_shiftl32:
450 ; X64-NOBMI2: # %bb.0:
451 ; X64-NOBMI2-NEXT: movl %esi, %ecx
452 ; X64-NOBMI2-NEXT: movl %edi, %eax
453 ; X64-NOBMI2-NEXT: notb %cl
454 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
455 ; X64-NOBMI2-NEXT: shll %cl, %eax
456 ; X64-NOBMI2-NEXT: retq
458 ; X64-BMI2-LABEL: xor31_shiftl32:
460 ; X64-BMI2-NEXT: notb %sil
461 ; X64-BMI2-NEXT: shlxl %esi, %edi, %eax
462 ; X64-BMI2-NEXT: retq
463 %adjcnt = xor i32 %cnt, 31
464 %result = shl i32 %val, %adjcnt
468 define i32 @sub63_shiftr32(i32 %val, i32 %cnt) nounwind {
469 ; X86-NOBMI2-LABEL: sub63_shiftr32:
470 ; X86-NOBMI2: # %bb.0:
471 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
472 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
473 ; X86-NOBMI2-NEXT: notb %cl
474 ; X86-NOBMI2-NEXT: shrl %cl, %eax
475 ; X86-NOBMI2-NEXT: retl
477 ; X86-BMI2-LABEL: sub63_shiftr32:
479 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
480 ; X86-BMI2-NEXT: notb %al
481 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %eax
482 ; X86-BMI2-NEXT: retl
484 ; X64-NOBMI2-LABEL: sub63_shiftr32:
485 ; X64-NOBMI2: # %bb.0:
486 ; X64-NOBMI2-NEXT: movl %esi, %ecx
487 ; X64-NOBMI2-NEXT: movl %edi, %eax
488 ; X64-NOBMI2-NEXT: notb %cl
489 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
490 ; X64-NOBMI2-NEXT: shrl %cl, %eax
491 ; X64-NOBMI2-NEXT: retq
493 ; X64-BMI2-LABEL: sub63_shiftr32:
495 ; X64-BMI2-NEXT: notb %sil
496 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
497 ; X64-BMI2-NEXT: retq
498 %adjcnt = sub i32 63, %cnt
499 %result = lshr i32 %val, %adjcnt
503 define i32 @xor63_shiftl32(i32 %val, i32 %cnt) nounwind {
504 ; X86-NOBMI2-LABEL: xor63_shiftl32:
505 ; X86-NOBMI2: # %bb.0:
506 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
507 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
508 ; X86-NOBMI2-NEXT: notb %cl
509 ; X86-NOBMI2-NEXT: shll %cl, %eax
510 ; X86-NOBMI2-NEXT: retl
512 ; X86-BMI2-LABEL: xor63_shiftl32:
514 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
515 ; X86-BMI2-NEXT: notb %al
516 ; X86-BMI2-NEXT: shlxl %eax, {{[0-9]+}}(%esp), %eax
517 ; X86-BMI2-NEXT: retl
519 ; X64-NOBMI2-LABEL: xor63_shiftl32:
520 ; X64-NOBMI2: # %bb.0:
521 ; X64-NOBMI2-NEXT: movl %esi, %ecx
522 ; X64-NOBMI2-NEXT: movl %edi, %eax
523 ; X64-NOBMI2-NEXT: notb %cl
524 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
525 ; X64-NOBMI2-NEXT: shll %cl, %eax
526 ; X64-NOBMI2-NEXT: retq
528 ; X64-BMI2-LABEL: xor63_shiftl32:
530 ; X64-BMI2-NEXT: notb %sil
531 ; X64-BMI2-NEXT: shlxl %esi, %edi, %eax
532 ; X64-BMI2-NEXT: retq
533 %adjcnt = xor i32 %cnt, 63
534 %result = shl i32 %val, %adjcnt
538 define i32 @xor32_shiftr32(i32 %val, i32 %cnt) nounwind {
539 ; X86-NOBMI2-LABEL: xor32_shiftr32:
540 ; X86-NOBMI2: # %bb.0:
541 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
542 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
543 ; X86-NOBMI2-NEXT: shrl %cl, %eax
544 ; X86-NOBMI2-NEXT: retl
546 ; X86-BMI2-LABEL: xor32_shiftr32:
548 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
549 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %eax
550 ; X86-BMI2-NEXT: retl
552 ; X64-NOBMI2-LABEL: xor32_shiftr32:
553 ; X64-NOBMI2: # %bb.0:
554 ; X64-NOBMI2-NEXT: movl %esi, %ecx
555 ; X64-NOBMI2-NEXT: movl %edi, %eax
556 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
557 ; X64-NOBMI2-NEXT: shrl %cl, %eax
558 ; X64-NOBMI2-NEXT: retq
560 ; X64-BMI2-LABEL: xor32_shiftr32:
562 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
563 ; X64-BMI2-NEXT: retq
564 %adjcnt = xor i32 %cnt, 32
565 %result = lshr i32 %val, %adjcnt
569 define i32 @sub1s_shiftl32(i32 %val, i32 %cnt) nounwind {
570 ; X86-NOBMI2-LABEL: sub1s_shiftl32:
571 ; X86-NOBMI2: # %bb.0:
572 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
573 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
574 ; X86-NOBMI2-NEXT: notb %cl
575 ; X86-NOBMI2-NEXT: shll %cl, %eax
576 ; X86-NOBMI2-NEXT: retl
578 ; X86-BMI2-LABEL: sub1s_shiftl32:
580 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
581 ; X86-BMI2-NEXT: notb %al
582 ; X86-BMI2-NEXT: shlxl %eax, {{[0-9]+}}(%esp), %eax
583 ; X86-BMI2-NEXT: retl
585 ; X64-NOBMI2-LABEL: sub1s_shiftl32:
586 ; X64-NOBMI2: # %bb.0:
587 ; X64-NOBMI2-NEXT: movl %esi, %ecx
588 ; X64-NOBMI2-NEXT: movl %edi, %eax
589 ; X64-NOBMI2-NEXT: notb %cl
590 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
591 ; X64-NOBMI2-NEXT: shll %cl, %eax
592 ; X64-NOBMI2-NEXT: retq
594 ; X64-BMI2-LABEL: sub1s_shiftl32:
596 ; X64-BMI2-NEXT: notb %sil
597 ; X64-BMI2-NEXT: shlxl %esi, %edi, %eax
598 ; X64-BMI2-NEXT: retq
599 %adjcnt = xor i32 %cnt, -1
600 %result = shl i32 %val, %adjcnt
604 define i32 @xor1s_shiftr32(i32 %val, i32 %cnt) nounwind {
605 ; X86-NOBMI2-LABEL: xor1s_shiftr32:
606 ; X86-NOBMI2: # %bb.0:
607 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
608 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
609 ; X86-NOBMI2-NEXT: notb %cl
610 ; X86-NOBMI2-NEXT: shrl %cl, %eax
611 ; X86-NOBMI2-NEXT: retl
613 ; X86-BMI2-LABEL: xor1s_shiftr32:
615 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
616 ; X86-BMI2-NEXT: notb %al
617 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %eax
618 ; X86-BMI2-NEXT: retl
620 ; X64-NOBMI2-LABEL: xor1s_shiftr32:
621 ; X64-NOBMI2: # %bb.0:
622 ; X64-NOBMI2-NEXT: movl %esi, %ecx
623 ; X64-NOBMI2-NEXT: movl %edi, %eax
624 ; X64-NOBMI2-NEXT: notb %cl
625 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
626 ; X64-NOBMI2-NEXT: shrl %cl, %eax
627 ; X64-NOBMI2-NEXT: retq
629 ; X64-BMI2-LABEL: xor1s_shiftr32:
631 ; X64-BMI2-NEXT: notb %sil
632 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
633 ; X64-BMI2-NEXT: retq
634 %adjcnt = xor i32 %cnt, -1
635 %result = lshr i32 %val, %adjcnt
638 define i32 @invalid_sub31(i32 %val, i32 %cnt) nounwind {
639 ; X86-NOBMI2-LABEL: invalid_sub31:
640 ; X86-NOBMI2: # %bb.0:
641 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
642 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
643 ; X86-NOBMI2-NEXT: addb $-31, %cl
644 ; X86-NOBMI2-NEXT: shll %cl, %eax
645 ; X86-NOBMI2-NEXT: retl
647 ; X86-BMI2-LABEL: invalid_sub31:
649 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
650 ; X86-BMI2-NEXT: addb $-31, %al
651 ; X86-BMI2-NEXT: shlxl %eax, {{[0-9]+}}(%esp), %eax
652 ; X86-BMI2-NEXT: retl
654 ; X64-NOBMI2-LABEL: invalid_sub31:
655 ; X64-NOBMI2: # %bb.0:
656 ; X64-NOBMI2-NEXT: # kill: def $esi killed $esi def $rsi
657 ; X64-NOBMI2-NEXT: movl %edi, %eax
658 ; X64-NOBMI2-NEXT: leal -31(%rsi), %ecx
659 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
660 ; X64-NOBMI2-NEXT: shll %cl, %eax
661 ; X64-NOBMI2-NEXT: retq
663 ; X64-BMI2-LABEL: invalid_sub31:
665 ; X64-BMI2-NEXT: addb $-31, %sil
666 ; X64-BMI2-NEXT: shlxl %esi, %edi, %eax
667 ; X64-BMI2-NEXT: retq
668 %adjcnt = sub i32 %cnt, 31
669 %result = shl i32 %val, %adjcnt
673 define i32 @invalid_add31(i32 %val, i32 %cnt) nounwind {
674 ; X86-NOBMI2-LABEL: invalid_add31:
675 ; X86-NOBMI2: # %bb.0:
676 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
677 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
678 ; X86-NOBMI2-NEXT: addb $31, %cl
679 ; X86-NOBMI2-NEXT: shll %cl, %eax
680 ; X86-NOBMI2-NEXT: retl
682 ; X86-BMI2-LABEL: invalid_add31:
684 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
685 ; X86-BMI2-NEXT: addb $31, %al
686 ; X86-BMI2-NEXT: shlxl %eax, {{[0-9]+}}(%esp), %eax
687 ; X86-BMI2-NEXT: retl
689 ; X64-NOBMI2-LABEL: invalid_add31:
690 ; X64-NOBMI2: # %bb.0:
691 ; X64-NOBMI2-NEXT: # kill: def $esi killed $esi def $rsi
692 ; X64-NOBMI2-NEXT: movl %edi, %eax
693 ; X64-NOBMI2-NEXT: leal 31(%rsi), %ecx
694 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
695 ; X64-NOBMI2-NEXT: shll %cl, %eax
696 ; X64-NOBMI2-NEXT: retq
698 ; X64-BMI2-LABEL: invalid_add31:
700 ; X64-BMI2-NEXT: addb $31, %sil
701 ; X64-BMI2-NEXT: shlxl %esi, %edi, %eax
702 ; X64-BMI2-NEXT: retq
703 %adjcnt = add i32 %cnt, 31
704 %result = shl i32 %val, %adjcnt