1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X86,X86-NOBMI2
3 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X86,X86-NOBMI2
4 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X86,X86-NOBMI2
5 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X86,X86-BMI2
6 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X86,X86-BMI2
7 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=-bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X64,X64-NOBMI2
8 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X64,X64-NOBMI2
9 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,+tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X64,X64-NOBMI2
10 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,+tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X64,X64-BMI2
11 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,-tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X64,X64-BMI2
15 ; ic) x & (-1 << (32 - y))
17 ; id) x >> (32 - y) << (32 - y)
18 ; are equivalent, but we prefer the second variant if we have BMI2.
20 ; ---------------------------------------------------------------------------- ;
22 ; ---------------------------------------------------------------------------- ;
26 define i8 @clear_lowbits8_c0(i8 %val, i8 %numlowbits) nounwind {
27 ; X86-LABEL: clear_lowbits8_c0:
29 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
30 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
31 ; X86-NEXT: shrb %cl, %al
32 ; X86-NEXT: shlb %cl, %al
35 ; X64-LABEL: clear_lowbits8_c0:
37 ; X64-NEXT: movl %esi, %ecx
38 ; X64-NEXT: movl %edi, %eax
39 ; X64-NEXT: shrb %cl, %al
40 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
41 ; X64-NEXT: shlb %cl, %al
42 ; X64-NEXT: # kill: def $al killed $al killed $eax
44 %mask = shl i8 -1, %numlowbits
45 %masked = and i8 %mask, %val
49 define i8 @clear_lowbits8_c2_load(ptr %w, i8 %numlowbits) nounwind {
50 ; X86-LABEL: clear_lowbits8_c2_load:
52 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
53 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
54 ; X86-NEXT: movzbl (%eax), %eax
55 ; X86-NEXT: shrb %cl, %al
56 ; X86-NEXT: shlb %cl, %al
59 ; X64-LABEL: clear_lowbits8_c2_load:
61 ; X64-NEXT: movl %esi, %ecx
62 ; X64-NEXT: movzbl (%rdi), %eax
63 ; X64-NEXT: shrb %cl, %al
64 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
65 ; X64-NEXT: shlb %cl, %al
67 %val = load i8, ptr %w
68 %mask = shl i8 -1, %numlowbits
69 %masked = and i8 %mask, %val
73 define i8 @clear_lowbits8_c4_commutative(i8 %val, i8 %numlowbits) nounwind {
74 ; X86-LABEL: clear_lowbits8_c4_commutative:
76 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
77 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
78 ; X86-NEXT: shrb %cl, %al
79 ; X86-NEXT: shlb %cl, %al
82 ; X64-LABEL: clear_lowbits8_c4_commutative:
84 ; X64-NEXT: movl %esi, %ecx
85 ; X64-NEXT: movl %edi, %eax
86 ; X64-NEXT: shrb %cl, %al
87 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
88 ; X64-NEXT: shlb %cl, %al
89 ; X64-NEXT: # kill: def $al killed $al killed $eax
91 %mask = shl i8 -1, %numlowbits
92 %masked = and i8 %val, %mask ; swapped order
98 define i16 @clear_lowbits16_c0(i16 %val, i16 %numlowbits) nounwind {
99 ; X86-NOBMI2-LABEL: clear_lowbits16_c0:
100 ; X86-NOBMI2: # %bb.0:
101 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
102 ; X86-NOBMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
103 ; X86-NOBMI2-NEXT: shrl %cl, %eax
104 ; X86-NOBMI2-NEXT: shll %cl, %eax
105 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
106 ; X86-NOBMI2-NEXT: retl
108 ; X86-BMI2-LABEL: clear_lowbits16_c0:
110 ; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
111 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
112 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
113 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
114 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
115 ; X86-BMI2-NEXT: retl
117 ; X64-NOBMI2-LABEL: clear_lowbits16_c0:
118 ; X64-NOBMI2: # %bb.0:
119 ; X64-NOBMI2-NEXT: movl %esi, %ecx
120 ; X64-NOBMI2-NEXT: movzwl %di, %eax
121 ; X64-NOBMI2-NEXT: shrl %cl, %eax
122 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
123 ; X64-NOBMI2-NEXT: shll %cl, %eax
124 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
125 ; X64-NOBMI2-NEXT: retq
127 ; X64-BMI2-LABEL: clear_lowbits16_c0:
129 ; X64-BMI2-NEXT: movzwl %di, %eax
130 ; X64-BMI2-NEXT: shrxl %esi, %eax, %eax
131 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
132 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
133 ; X64-BMI2-NEXT: retq
134 %mask = shl i16 -1, %numlowbits
135 %masked = and i16 %mask, %val
139 define i16 @clear_lowbits16_c1_indexzext(i16 %val, i8 %numlowbits) nounwind {
140 ; X86-NOBMI2-LABEL: clear_lowbits16_c1_indexzext:
141 ; X86-NOBMI2: # %bb.0:
142 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
143 ; X86-NOBMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
144 ; X86-NOBMI2-NEXT: shrl %cl, %eax
145 ; X86-NOBMI2-NEXT: shll %cl, %eax
146 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
147 ; X86-NOBMI2-NEXT: retl
149 ; X86-BMI2-LABEL: clear_lowbits16_c1_indexzext:
151 ; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
152 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
153 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
154 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
155 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
156 ; X86-BMI2-NEXT: retl
158 ; X64-NOBMI2-LABEL: clear_lowbits16_c1_indexzext:
159 ; X64-NOBMI2: # %bb.0:
160 ; X64-NOBMI2-NEXT: movl %esi, %ecx
161 ; X64-NOBMI2-NEXT: movzwl %di, %eax
162 ; X64-NOBMI2-NEXT: shrl %cl, %eax
163 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
164 ; X64-NOBMI2-NEXT: shll %cl, %eax
165 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
166 ; X64-NOBMI2-NEXT: retq
168 ; X64-BMI2-LABEL: clear_lowbits16_c1_indexzext:
170 ; X64-BMI2-NEXT: movzwl %di, %eax
171 ; X64-BMI2-NEXT: shrxl %esi, %eax, %eax
172 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
173 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
174 ; X64-BMI2-NEXT: retq
175 %sh_prom = zext i8 %numlowbits to i16
176 %mask = shl i16 -1, %sh_prom
177 %masked = and i16 %mask, %val
181 define i16 @clear_lowbits16_c2_load(ptr %w, i16 %numlowbits) nounwind {
182 ; X86-NOBMI2-LABEL: clear_lowbits16_c2_load:
183 ; X86-NOBMI2: # %bb.0:
184 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
185 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
186 ; X86-NOBMI2-NEXT: movzwl (%eax), %eax
187 ; X86-NOBMI2-NEXT: shrl %cl, %eax
188 ; X86-NOBMI2-NEXT: shll %cl, %eax
189 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
190 ; X86-NOBMI2-NEXT: retl
192 ; X86-BMI2-LABEL: clear_lowbits16_c2_load:
194 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
195 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
196 ; X86-BMI2-NEXT: movzwl (%ecx), %ecx
197 ; X86-BMI2-NEXT: shrxl %eax, %ecx, %ecx
198 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
199 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
200 ; X86-BMI2-NEXT: retl
202 ; X64-NOBMI2-LABEL: clear_lowbits16_c2_load:
203 ; X64-NOBMI2: # %bb.0:
204 ; X64-NOBMI2-NEXT: movl %esi, %ecx
205 ; X64-NOBMI2-NEXT: movzwl (%rdi), %eax
206 ; X64-NOBMI2-NEXT: shrl %cl, %eax
207 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
208 ; X64-NOBMI2-NEXT: shll %cl, %eax
209 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
210 ; X64-NOBMI2-NEXT: retq
212 ; X64-BMI2-LABEL: clear_lowbits16_c2_load:
214 ; X64-BMI2-NEXT: movzwl (%rdi), %eax
215 ; X64-BMI2-NEXT: shrxl %esi, %eax, %eax
216 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
217 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
218 ; X64-BMI2-NEXT: retq
219 %val = load i16, ptr %w
220 %mask = shl i16 -1, %numlowbits
221 %masked = and i16 %mask, %val
225 define i16 @clear_lowbits16_c3_load_indexzext(ptr %w, i8 %numlowbits) nounwind {
226 ; X86-NOBMI2-LABEL: clear_lowbits16_c3_load_indexzext:
227 ; X86-NOBMI2: # %bb.0:
228 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
229 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
230 ; X86-NOBMI2-NEXT: movzwl (%eax), %eax
231 ; X86-NOBMI2-NEXT: shrl %cl, %eax
232 ; X86-NOBMI2-NEXT: shll %cl, %eax
233 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
234 ; X86-NOBMI2-NEXT: retl
236 ; X86-BMI2-LABEL: clear_lowbits16_c3_load_indexzext:
238 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
239 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
240 ; X86-BMI2-NEXT: movzwl (%ecx), %ecx
241 ; X86-BMI2-NEXT: shrxl %eax, %ecx, %ecx
242 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
243 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
244 ; X86-BMI2-NEXT: retl
246 ; X64-NOBMI2-LABEL: clear_lowbits16_c3_load_indexzext:
247 ; X64-NOBMI2: # %bb.0:
248 ; X64-NOBMI2-NEXT: movl %esi, %ecx
249 ; X64-NOBMI2-NEXT: movzwl (%rdi), %eax
250 ; X64-NOBMI2-NEXT: shrl %cl, %eax
251 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
252 ; X64-NOBMI2-NEXT: shll %cl, %eax
253 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
254 ; X64-NOBMI2-NEXT: retq
256 ; X64-BMI2-LABEL: clear_lowbits16_c3_load_indexzext:
258 ; X64-BMI2-NEXT: movzwl (%rdi), %eax
259 ; X64-BMI2-NEXT: shrxl %esi, %eax, %eax
260 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
261 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
262 ; X64-BMI2-NEXT: retq
263 %val = load i16, ptr %w
264 %sh_prom = zext i8 %numlowbits to i16
265 %mask = shl i16 -1, %sh_prom
266 %masked = and i16 %mask, %val
270 define i16 @clear_lowbits16_c4_commutative(i16 %val, i16 %numlowbits) nounwind {
271 ; X86-NOBMI2-LABEL: clear_lowbits16_c4_commutative:
272 ; X86-NOBMI2: # %bb.0:
273 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
274 ; X86-NOBMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
275 ; X86-NOBMI2-NEXT: shrl %cl, %eax
276 ; X86-NOBMI2-NEXT: shll %cl, %eax
277 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
278 ; X86-NOBMI2-NEXT: retl
280 ; X86-BMI2-LABEL: clear_lowbits16_c4_commutative:
282 ; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
283 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
284 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
285 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
286 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
287 ; X86-BMI2-NEXT: retl
289 ; X64-NOBMI2-LABEL: clear_lowbits16_c4_commutative:
290 ; X64-NOBMI2: # %bb.0:
291 ; X64-NOBMI2-NEXT: movl %esi, %ecx
292 ; X64-NOBMI2-NEXT: movzwl %di, %eax
293 ; X64-NOBMI2-NEXT: shrl %cl, %eax
294 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
295 ; X64-NOBMI2-NEXT: shll %cl, %eax
296 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
297 ; X64-NOBMI2-NEXT: retq
299 ; X64-BMI2-LABEL: clear_lowbits16_c4_commutative:
301 ; X64-BMI2-NEXT: movzwl %di, %eax
302 ; X64-BMI2-NEXT: shrxl %esi, %eax, %eax
303 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
304 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
305 ; X64-BMI2-NEXT: retq
306 %mask = shl i16 -1, %numlowbits
307 %masked = and i16 %val, %mask ; swapped order
313 define i32 @clear_lowbits32_c0(i32 %val, i32 %numlowbits) nounwind {
314 ; X86-NOBMI2-LABEL: clear_lowbits32_c0:
315 ; X86-NOBMI2: # %bb.0:
316 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
317 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
318 ; X86-NOBMI2-NEXT: shrl %cl, %eax
319 ; X86-NOBMI2-NEXT: shll %cl, %eax
320 ; X86-NOBMI2-NEXT: retl
322 ; X86-BMI2-LABEL: clear_lowbits32_c0:
324 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
325 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx
326 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
327 ; X86-BMI2-NEXT: retl
329 ; X64-NOBMI2-LABEL: clear_lowbits32_c0:
330 ; X64-NOBMI2: # %bb.0:
331 ; X64-NOBMI2-NEXT: movl %esi, %ecx
332 ; X64-NOBMI2-NEXT: movl %edi, %eax
333 ; X64-NOBMI2-NEXT: shrl %cl, %eax
334 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
335 ; X64-NOBMI2-NEXT: shll %cl, %eax
336 ; X64-NOBMI2-NEXT: retq
338 ; X64-BMI2-LABEL: clear_lowbits32_c0:
340 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
341 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
342 ; X64-BMI2-NEXT: retq
343 %mask = shl i32 -1, %numlowbits
344 %masked = and i32 %mask, %val
348 define i32 @clear_lowbits32_c1_indexzext(i32 %val, i8 %numlowbits) nounwind {
349 ; X86-NOBMI2-LABEL: clear_lowbits32_c1_indexzext:
350 ; X86-NOBMI2: # %bb.0:
351 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
352 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
353 ; X86-NOBMI2-NEXT: shrl %cl, %eax
354 ; X86-NOBMI2-NEXT: shll %cl, %eax
355 ; X86-NOBMI2-NEXT: retl
357 ; X86-BMI2-LABEL: clear_lowbits32_c1_indexzext:
359 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
360 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx
361 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
362 ; X86-BMI2-NEXT: retl
364 ; X64-NOBMI2-LABEL: clear_lowbits32_c1_indexzext:
365 ; X64-NOBMI2: # %bb.0:
366 ; X64-NOBMI2-NEXT: movl %esi, %ecx
367 ; X64-NOBMI2-NEXT: movl %edi, %eax
368 ; X64-NOBMI2-NEXT: shrl %cl, %eax
369 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
370 ; X64-NOBMI2-NEXT: shll %cl, %eax
371 ; X64-NOBMI2-NEXT: retq
373 ; X64-BMI2-LABEL: clear_lowbits32_c1_indexzext:
375 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
376 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
377 ; X64-BMI2-NEXT: retq
378 %sh_prom = zext i8 %numlowbits to i32
379 %mask = shl i32 -1, %sh_prom
380 %masked = and i32 %mask, %val
384 define i32 @clear_lowbits32_c2_load(ptr %w, i32 %numlowbits) nounwind {
385 ; X86-NOBMI2-LABEL: clear_lowbits32_c2_load:
386 ; X86-NOBMI2: # %bb.0:
387 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
388 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
389 ; X86-NOBMI2-NEXT: movl (%eax), %eax
390 ; X86-NOBMI2-NEXT: shrl %cl, %eax
391 ; X86-NOBMI2-NEXT: shll %cl, %eax
392 ; X86-NOBMI2-NEXT: retl
394 ; X86-BMI2-LABEL: clear_lowbits32_c2_load:
396 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
397 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
398 ; X86-BMI2-NEXT: shrxl %ecx, (%eax), %eax
399 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
400 ; X86-BMI2-NEXT: retl
402 ; X64-NOBMI2-LABEL: clear_lowbits32_c2_load:
403 ; X64-NOBMI2: # %bb.0:
404 ; X64-NOBMI2-NEXT: movl %esi, %ecx
405 ; X64-NOBMI2-NEXT: movl (%rdi), %eax
406 ; X64-NOBMI2-NEXT: shrl %cl, %eax
407 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
408 ; X64-NOBMI2-NEXT: shll %cl, %eax
409 ; X64-NOBMI2-NEXT: retq
411 ; X64-BMI2-LABEL: clear_lowbits32_c2_load:
413 ; X64-BMI2-NEXT: shrxl %esi, (%rdi), %eax
414 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
415 ; X64-BMI2-NEXT: retq
416 %val = load i32, ptr %w
417 %mask = shl i32 -1, %numlowbits
418 %masked = and i32 %mask, %val
422 define i32 @clear_lowbits32_c3_load_indexzext(ptr %w, i8 %numlowbits) nounwind {
423 ; X86-NOBMI2-LABEL: clear_lowbits32_c3_load_indexzext:
424 ; X86-NOBMI2: # %bb.0:
425 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
426 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
427 ; X86-NOBMI2-NEXT: movl (%eax), %eax
428 ; X86-NOBMI2-NEXT: shrl %cl, %eax
429 ; X86-NOBMI2-NEXT: shll %cl, %eax
430 ; X86-NOBMI2-NEXT: retl
432 ; X86-BMI2-LABEL: clear_lowbits32_c3_load_indexzext:
434 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
435 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
436 ; X86-BMI2-NEXT: shrxl %ecx, (%eax), %eax
437 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
438 ; X86-BMI2-NEXT: retl
440 ; X64-NOBMI2-LABEL: clear_lowbits32_c3_load_indexzext:
441 ; X64-NOBMI2: # %bb.0:
442 ; X64-NOBMI2-NEXT: movl %esi, %ecx
443 ; X64-NOBMI2-NEXT: movl (%rdi), %eax
444 ; X64-NOBMI2-NEXT: shrl %cl, %eax
445 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
446 ; X64-NOBMI2-NEXT: shll %cl, %eax
447 ; X64-NOBMI2-NEXT: retq
449 ; X64-BMI2-LABEL: clear_lowbits32_c3_load_indexzext:
451 ; X64-BMI2-NEXT: shrxl %esi, (%rdi), %eax
452 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
453 ; X64-BMI2-NEXT: retq
454 %val = load i32, ptr %w
455 %sh_prom = zext i8 %numlowbits to i32
456 %mask = shl i32 -1, %sh_prom
457 %masked = and i32 %mask, %val
461 define i32 @clear_lowbits32_c4_commutative(i32 %val, i32 %numlowbits) nounwind {
462 ; X86-NOBMI2-LABEL: clear_lowbits32_c4_commutative:
463 ; X86-NOBMI2: # %bb.0:
464 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
465 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
466 ; X86-NOBMI2-NEXT: shrl %cl, %eax
467 ; X86-NOBMI2-NEXT: shll %cl, %eax
468 ; X86-NOBMI2-NEXT: retl
470 ; X86-BMI2-LABEL: clear_lowbits32_c4_commutative:
472 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
473 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx
474 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
475 ; X86-BMI2-NEXT: retl
477 ; X64-NOBMI2-LABEL: clear_lowbits32_c4_commutative:
478 ; X64-NOBMI2: # %bb.0:
479 ; X64-NOBMI2-NEXT: movl %esi, %ecx
480 ; X64-NOBMI2-NEXT: movl %edi, %eax
481 ; X64-NOBMI2-NEXT: shrl %cl, %eax
482 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
483 ; X64-NOBMI2-NEXT: shll %cl, %eax
484 ; X64-NOBMI2-NEXT: retq
486 ; X64-BMI2-LABEL: clear_lowbits32_c4_commutative:
488 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
489 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
490 ; X64-BMI2-NEXT: retq
491 %mask = shl i32 -1, %numlowbits
492 %masked = and i32 %val, %mask ; swapped order
498 define i64 @clear_lowbits64_c0(i64 %val, i64 %numlowbits) nounwind {
499 ; X86-NOBMI2-LABEL: clear_lowbits64_c0:
500 ; X86-NOBMI2: # %bb.0:
501 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
502 ; X86-NOBMI2-NEXT: movl $-1, %edx
503 ; X86-NOBMI2-NEXT: movl $-1, %eax
504 ; X86-NOBMI2-NEXT: shll %cl, %eax
505 ; X86-NOBMI2-NEXT: testb $32, %cl
506 ; X86-NOBMI2-NEXT: je .LBB13_2
507 ; X86-NOBMI2-NEXT: # %bb.1:
508 ; X86-NOBMI2-NEXT: movl %eax, %edx
509 ; X86-NOBMI2-NEXT: xorl %eax, %eax
510 ; X86-NOBMI2-NEXT: .LBB13_2:
511 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
512 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
513 ; X86-NOBMI2-NEXT: retl
515 ; X86-BMI2-LABEL: clear_lowbits64_c0:
517 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
518 ; X86-BMI2-NEXT: movl $-1, %edx
519 ; X86-BMI2-NEXT: shlxl %ecx, %edx, %eax
520 ; X86-BMI2-NEXT: testb $32, %cl
521 ; X86-BMI2-NEXT: je .LBB13_2
522 ; X86-BMI2-NEXT: # %bb.1:
523 ; X86-BMI2-NEXT: movl %eax, %edx
524 ; X86-BMI2-NEXT: xorl %eax, %eax
525 ; X86-BMI2-NEXT: .LBB13_2:
526 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
527 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
528 ; X86-BMI2-NEXT: retl
530 ; X64-NOBMI2-LABEL: clear_lowbits64_c0:
531 ; X64-NOBMI2: # %bb.0:
532 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
533 ; X64-NOBMI2-NEXT: movq %rdi, %rax
534 ; X64-NOBMI2-NEXT: shrq %cl, %rax
535 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
536 ; X64-NOBMI2-NEXT: shlq %cl, %rax
537 ; X64-NOBMI2-NEXT: retq
539 ; X64-BMI2-LABEL: clear_lowbits64_c0:
541 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
542 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
543 ; X64-BMI2-NEXT: retq
544 %mask = shl i64 -1, %numlowbits
545 %masked = and i64 %mask, %val
549 define i64 @clear_lowbits64_c1_indexzext(i64 %val, i8 %numlowbits) nounwind {
550 ; X86-NOBMI2-LABEL: clear_lowbits64_c1_indexzext:
551 ; X86-NOBMI2: # %bb.0:
552 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
553 ; X86-NOBMI2-NEXT: movl $-1, %edx
554 ; X86-NOBMI2-NEXT: movl $-1, %eax
555 ; X86-NOBMI2-NEXT: shll %cl, %eax
556 ; X86-NOBMI2-NEXT: testb $32, %cl
557 ; X86-NOBMI2-NEXT: je .LBB14_2
558 ; X86-NOBMI2-NEXT: # %bb.1:
559 ; X86-NOBMI2-NEXT: movl %eax, %edx
560 ; X86-NOBMI2-NEXT: xorl %eax, %eax
561 ; X86-NOBMI2-NEXT: .LBB14_2:
562 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
563 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
564 ; X86-NOBMI2-NEXT: retl
566 ; X86-BMI2-LABEL: clear_lowbits64_c1_indexzext:
568 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
569 ; X86-BMI2-NEXT: movl $-1, %edx
570 ; X86-BMI2-NEXT: shlxl %ecx, %edx, %eax
571 ; X86-BMI2-NEXT: testb $32, %cl
572 ; X86-BMI2-NEXT: je .LBB14_2
573 ; X86-BMI2-NEXT: # %bb.1:
574 ; X86-BMI2-NEXT: movl %eax, %edx
575 ; X86-BMI2-NEXT: xorl %eax, %eax
576 ; X86-BMI2-NEXT: .LBB14_2:
577 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
578 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
579 ; X86-BMI2-NEXT: retl
581 ; X64-NOBMI2-LABEL: clear_lowbits64_c1_indexzext:
582 ; X64-NOBMI2: # %bb.0:
583 ; X64-NOBMI2-NEXT: movl %esi, %ecx
584 ; X64-NOBMI2-NEXT: movq %rdi, %rax
585 ; X64-NOBMI2-NEXT: shrq %cl, %rax
586 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
587 ; X64-NOBMI2-NEXT: shlq %cl, %rax
588 ; X64-NOBMI2-NEXT: retq
590 ; X64-BMI2-LABEL: clear_lowbits64_c1_indexzext:
592 ; X64-BMI2-NEXT: # kill: def $esi killed $esi def $rsi
593 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
594 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
595 ; X64-BMI2-NEXT: retq
596 %sh_prom = zext i8 %numlowbits to i64
597 %mask = shl i64 -1, %sh_prom
598 %masked = and i64 %mask, %val
602 define i64 @clear_lowbits64_c2_load(ptr %w, i64 %numlowbits) nounwind {
603 ; X86-NOBMI2-LABEL: clear_lowbits64_c2_load:
604 ; X86-NOBMI2: # %bb.0:
605 ; X86-NOBMI2-NEXT: pushl %esi
606 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
607 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
608 ; X86-NOBMI2-NEXT: movl $-1, %edx
609 ; X86-NOBMI2-NEXT: movl $-1, %eax
610 ; X86-NOBMI2-NEXT: shll %cl, %eax
611 ; X86-NOBMI2-NEXT: testb $32, %cl
612 ; X86-NOBMI2-NEXT: je .LBB15_2
613 ; X86-NOBMI2-NEXT: # %bb.1:
614 ; X86-NOBMI2-NEXT: movl %eax, %edx
615 ; X86-NOBMI2-NEXT: xorl %eax, %eax
616 ; X86-NOBMI2-NEXT: .LBB15_2:
617 ; X86-NOBMI2-NEXT: andl (%esi), %eax
618 ; X86-NOBMI2-NEXT: andl 4(%esi), %edx
619 ; X86-NOBMI2-NEXT: popl %esi
620 ; X86-NOBMI2-NEXT: retl
622 ; X86-BMI2-LABEL: clear_lowbits64_c2_load:
624 ; X86-BMI2-NEXT: pushl %ebx
625 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
626 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ebx
627 ; X86-BMI2-NEXT: movl $-1, %edx
628 ; X86-BMI2-NEXT: shlxl %ebx, %edx, %eax
629 ; X86-BMI2-NEXT: testb $32, %bl
630 ; X86-BMI2-NEXT: je .LBB15_2
631 ; X86-BMI2-NEXT: # %bb.1:
632 ; X86-BMI2-NEXT: movl %eax, %edx
633 ; X86-BMI2-NEXT: xorl %eax, %eax
634 ; X86-BMI2-NEXT: .LBB15_2:
635 ; X86-BMI2-NEXT: andl (%ecx), %eax
636 ; X86-BMI2-NEXT: andl 4(%ecx), %edx
637 ; X86-BMI2-NEXT: popl %ebx
638 ; X86-BMI2-NEXT: retl
640 ; X64-NOBMI2-LABEL: clear_lowbits64_c2_load:
641 ; X64-NOBMI2: # %bb.0:
642 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
643 ; X64-NOBMI2-NEXT: movq (%rdi), %rax
644 ; X64-NOBMI2-NEXT: shrq %cl, %rax
645 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
646 ; X64-NOBMI2-NEXT: shlq %cl, %rax
647 ; X64-NOBMI2-NEXT: retq
649 ; X64-BMI2-LABEL: clear_lowbits64_c2_load:
651 ; X64-BMI2-NEXT: shrxq %rsi, (%rdi), %rax
652 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
653 ; X64-BMI2-NEXT: retq
654 %val = load i64, ptr %w
655 %mask = shl i64 -1, %numlowbits
656 %masked = and i64 %mask, %val
660 define i64 @clear_lowbits64_c3_load_indexzext(ptr %w, i8 %numlowbits) nounwind {
661 ; X86-NOBMI2-LABEL: clear_lowbits64_c3_load_indexzext:
662 ; X86-NOBMI2: # %bb.0:
663 ; X86-NOBMI2-NEXT: pushl %esi
664 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
665 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
666 ; X86-NOBMI2-NEXT: movl $-1, %edx
667 ; X86-NOBMI2-NEXT: movl $-1, %eax
668 ; X86-NOBMI2-NEXT: shll %cl, %eax
669 ; X86-NOBMI2-NEXT: testb $32, %cl
670 ; X86-NOBMI2-NEXT: je .LBB16_2
671 ; X86-NOBMI2-NEXT: # %bb.1:
672 ; X86-NOBMI2-NEXT: movl %eax, %edx
673 ; X86-NOBMI2-NEXT: xorl %eax, %eax
674 ; X86-NOBMI2-NEXT: .LBB16_2:
675 ; X86-NOBMI2-NEXT: andl (%esi), %eax
676 ; X86-NOBMI2-NEXT: andl 4(%esi), %edx
677 ; X86-NOBMI2-NEXT: popl %esi
678 ; X86-NOBMI2-NEXT: retl
680 ; X86-BMI2-LABEL: clear_lowbits64_c3_load_indexzext:
682 ; X86-BMI2-NEXT: pushl %ebx
683 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
684 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ebx
685 ; X86-BMI2-NEXT: movl $-1, %edx
686 ; X86-BMI2-NEXT: shlxl %ebx, %edx, %eax
687 ; X86-BMI2-NEXT: testb $32, %bl
688 ; X86-BMI2-NEXT: je .LBB16_2
689 ; X86-BMI2-NEXT: # %bb.1:
690 ; X86-BMI2-NEXT: movl %eax, %edx
691 ; X86-BMI2-NEXT: xorl %eax, %eax
692 ; X86-BMI2-NEXT: .LBB16_2:
693 ; X86-BMI2-NEXT: andl (%ecx), %eax
694 ; X86-BMI2-NEXT: andl 4(%ecx), %edx
695 ; X86-BMI2-NEXT: popl %ebx
696 ; X86-BMI2-NEXT: retl
698 ; X64-NOBMI2-LABEL: clear_lowbits64_c3_load_indexzext:
699 ; X64-NOBMI2: # %bb.0:
700 ; X64-NOBMI2-NEXT: movl %esi, %ecx
701 ; X64-NOBMI2-NEXT: movq (%rdi), %rax
702 ; X64-NOBMI2-NEXT: shrq %cl, %rax
703 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
704 ; X64-NOBMI2-NEXT: shlq %cl, %rax
705 ; X64-NOBMI2-NEXT: retq
707 ; X64-BMI2-LABEL: clear_lowbits64_c3_load_indexzext:
709 ; X64-BMI2-NEXT: # kill: def $esi killed $esi def $rsi
710 ; X64-BMI2-NEXT: shrxq %rsi, (%rdi), %rax
711 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
712 ; X64-BMI2-NEXT: retq
713 %val = load i64, ptr %w
714 %sh_prom = zext i8 %numlowbits to i64
715 %mask = shl i64 -1, %sh_prom
716 %masked = and i64 %mask, %val
720 define i64 @clear_lowbits64_c4_commutative(i64 %val, i64 %numlowbits) nounwind {
721 ; X86-NOBMI2-LABEL: clear_lowbits64_c4_commutative:
722 ; X86-NOBMI2: # %bb.0:
723 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
724 ; X86-NOBMI2-NEXT: movl $-1, %edx
725 ; X86-NOBMI2-NEXT: movl $-1, %eax
726 ; X86-NOBMI2-NEXT: shll %cl, %eax
727 ; X86-NOBMI2-NEXT: testb $32, %cl
728 ; X86-NOBMI2-NEXT: je .LBB17_2
729 ; X86-NOBMI2-NEXT: # %bb.1:
730 ; X86-NOBMI2-NEXT: movl %eax, %edx
731 ; X86-NOBMI2-NEXT: xorl %eax, %eax
732 ; X86-NOBMI2-NEXT: .LBB17_2:
733 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
734 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
735 ; X86-NOBMI2-NEXT: retl
737 ; X86-BMI2-LABEL: clear_lowbits64_c4_commutative:
739 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
740 ; X86-BMI2-NEXT: movl $-1, %edx
741 ; X86-BMI2-NEXT: shlxl %ecx, %edx, %eax
742 ; X86-BMI2-NEXT: testb $32, %cl
743 ; X86-BMI2-NEXT: je .LBB17_2
744 ; X86-BMI2-NEXT: # %bb.1:
745 ; X86-BMI2-NEXT: movl %eax, %edx
746 ; X86-BMI2-NEXT: xorl %eax, %eax
747 ; X86-BMI2-NEXT: .LBB17_2:
748 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
749 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
750 ; X86-BMI2-NEXT: retl
752 ; X64-NOBMI2-LABEL: clear_lowbits64_c4_commutative:
753 ; X64-NOBMI2: # %bb.0:
754 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
755 ; X64-NOBMI2-NEXT: movq %rdi, %rax
756 ; X64-NOBMI2-NEXT: shrq %cl, %rax
757 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
758 ; X64-NOBMI2-NEXT: shlq %cl, %rax
759 ; X64-NOBMI2-NEXT: retq
761 ; X64-BMI2-LABEL: clear_lowbits64_c4_commutative:
763 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
764 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
765 ; X64-BMI2-NEXT: retq
766 %mask = shl i64 -1, %numlowbits
767 %masked = and i64 %val, %mask ; swapped order
771 ; ---------------------------------------------------------------------------- ;
773 ; ---------------------------------------------------------------------------- ;
777 define i8 @clear_lowbits8_ic0(i8 %val, i8 %numlowbits) nounwind {
778 ; X86-LABEL: clear_lowbits8_ic0:
780 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
781 ; X86-NEXT: movb $8, %cl
782 ; X86-NEXT: subb {{[0-9]+}}(%esp), %cl
783 ; X86-NEXT: shrb %cl, %al
784 ; X86-NEXT: shlb %cl, %al
787 ; X64-LABEL: clear_lowbits8_ic0:
789 ; X64-NEXT: movl %edi, %eax
790 ; X64-NEXT: movb $8, %cl
791 ; X64-NEXT: subb %sil, %cl
792 ; X64-NEXT: shrb %cl, %al
793 ; X64-NEXT: shlb %cl, %al
794 ; X64-NEXT: # kill: def $al killed $al killed $eax
796 %numhighbits = sub i8 8, %numlowbits
797 %mask = shl i8 -1, %numhighbits
798 %masked = and i8 %mask, %val
802 define i8 @clear_lowbits8_ic2_load(ptr %w, i8 %numlowbits) nounwind {
803 ; X86-LABEL: clear_lowbits8_ic2_load:
805 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
806 ; X86-NEXT: movzbl (%eax), %eax
807 ; X86-NEXT: movb $8, %cl
808 ; X86-NEXT: subb {{[0-9]+}}(%esp), %cl
809 ; X86-NEXT: shrb %cl, %al
810 ; X86-NEXT: shlb %cl, %al
813 ; X64-LABEL: clear_lowbits8_ic2_load:
815 ; X64-NEXT: movzbl (%rdi), %eax
816 ; X64-NEXT: movb $8, %cl
817 ; X64-NEXT: subb %sil, %cl
818 ; X64-NEXT: shrb %cl, %al
819 ; X64-NEXT: shlb %cl, %al
821 %val = load i8, ptr %w
822 %numhighbits = sub i8 8, %numlowbits
823 %mask = shl i8 -1, %numhighbits
824 %masked = and i8 %mask, %val
828 define i8 @clear_lowbits8_ic4_commutative(i8 %val, i8 %numlowbits) nounwind {
829 ; X86-LABEL: clear_lowbits8_ic4_commutative:
831 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
832 ; X86-NEXT: movb $8, %cl
833 ; X86-NEXT: subb {{[0-9]+}}(%esp), %cl
834 ; X86-NEXT: shrb %cl, %al
835 ; X86-NEXT: shlb %cl, %al
838 ; X64-LABEL: clear_lowbits8_ic4_commutative:
840 ; X64-NEXT: movl %edi, %eax
841 ; X64-NEXT: movb $8, %cl
842 ; X64-NEXT: subb %sil, %cl
843 ; X64-NEXT: shrb %cl, %al
844 ; X64-NEXT: shlb %cl, %al
845 ; X64-NEXT: # kill: def $al killed $al killed $eax
847 %numhighbits = sub i8 8, %numlowbits
848 %mask = shl i8 -1, %numhighbits
849 %masked = and i8 %val, %mask ; swapped order
855 define i16 @clear_lowbits16_ic0(i16 %val, i16 %numlowbits) nounwind {
856 ; X86-NOBMI2-LABEL: clear_lowbits16_ic0:
857 ; X86-NOBMI2: # %bb.0:
858 ; X86-NOBMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
859 ; X86-NOBMI2-NEXT: movb $16, %cl
860 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
861 ; X86-NOBMI2-NEXT: shrl %cl, %eax
862 ; X86-NOBMI2-NEXT: shll %cl, %eax
863 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
864 ; X86-NOBMI2-NEXT: retl
866 ; X86-BMI2-LABEL: clear_lowbits16_ic0:
868 ; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
869 ; X86-BMI2-NEXT: movb $16, %cl
870 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
871 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
872 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
873 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
874 ; X86-BMI2-NEXT: retl
876 ; X64-NOBMI2-LABEL: clear_lowbits16_ic0:
877 ; X64-NOBMI2: # %bb.0:
878 ; X64-NOBMI2-NEXT: movzwl %di, %eax
879 ; X64-NOBMI2-NEXT: movb $16, %cl
880 ; X64-NOBMI2-NEXT: subb %sil, %cl
881 ; X64-NOBMI2-NEXT: shrl %cl, %eax
882 ; X64-NOBMI2-NEXT: shll %cl, %eax
883 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
884 ; X64-NOBMI2-NEXT: retq
886 ; X64-BMI2-LABEL: clear_lowbits16_ic0:
888 ; X64-BMI2-NEXT: movzwl %di, %eax
889 ; X64-BMI2-NEXT: movb $16, %cl
890 ; X64-BMI2-NEXT: subb %sil, %cl
891 ; X64-BMI2-NEXT: shrxl %ecx, %eax, %eax
892 ; X64-BMI2-NEXT: shlxl %ecx, %eax, %eax
893 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
894 ; X64-BMI2-NEXT: retq
895 %numhighbits = sub i16 16, %numlowbits
896 %mask = shl i16 -1, %numhighbits
897 %masked = and i16 %mask, %val
901 define i16 @clear_lowbits16_ic1_indexzext(i16 %val, i8 %numlowbits) nounwind {
902 ; X86-NOBMI2-LABEL: clear_lowbits16_ic1_indexzext:
903 ; X86-NOBMI2: # %bb.0:
904 ; X86-NOBMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
905 ; X86-NOBMI2-NEXT: movb $16, %cl
906 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
907 ; X86-NOBMI2-NEXT: shrl %cl, %eax
908 ; X86-NOBMI2-NEXT: shll %cl, %eax
909 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
910 ; X86-NOBMI2-NEXT: retl
912 ; X86-BMI2-LABEL: clear_lowbits16_ic1_indexzext:
914 ; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
915 ; X86-BMI2-NEXT: movb $16, %cl
916 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
917 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
918 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
919 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
920 ; X86-BMI2-NEXT: retl
922 ; X64-NOBMI2-LABEL: clear_lowbits16_ic1_indexzext:
923 ; X64-NOBMI2: # %bb.0:
924 ; X64-NOBMI2-NEXT: movzwl %di, %eax
925 ; X64-NOBMI2-NEXT: movb $16, %cl
926 ; X64-NOBMI2-NEXT: subb %sil, %cl
927 ; X64-NOBMI2-NEXT: shrl %cl, %eax
928 ; X64-NOBMI2-NEXT: shll %cl, %eax
929 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
930 ; X64-NOBMI2-NEXT: retq
932 ; X64-BMI2-LABEL: clear_lowbits16_ic1_indexzext:
934 ; X64-BMI2-NEXT: movzwl %di, %eax
935 ; X64-BMI2-NEXT: movb $16, %cl
936 ; X64-BMI2-NEXT: subb %sil, %cl
937 ; X64-BMI2-NEXT: shrxl %ecx, %eax, %eax
938 ; X64-BMI2-NEXT: shlxl %ecx, %eax, %eax
939 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
940 ; X64-BMI2-NEXT: retq
941 %numhighbits = sub i8 16, %numlowbits
942 %sh_prom = zext i8 %numhighbits to i16
943 %mask = shl i16 -1, %sh_prom
944 %masked = and i16 %mask, %val
948 define i16 @clear_lowbits16_ic2_load(ptr %w, i16 %numlowbits) nounwind {
949 ; X86-NOBMI2-LABEL: clear_lowbits16_ic2_load:
950 ; X86-NOBMI2: # %bb.0:
951 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
952 ; X86-NOBMI2-NEXT: movzwl (%eax), %eax
953 ; X86-NOBMI2-NEXT: movb $16, %cl
954 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
955 ; X86-NOBMI2-NEXT: shrl %cl, %eax
956 ; X86-NOBMI2-NEXT: shll %cl, %eax
957 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
958 ; X86-NOBMI2-NEXT: retl
960 ; X86-BMI2-LABEL: clear_lowbits16_ic2_load:
962 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
963 ; X86-BMI2-NEXT: movzwl (%eax), %eax
964 ; X86-BMI2-NEXT: movb $16, %cl
965 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
966 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
967 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
968 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
969 ; X86-BMI2-NEXT: retl
971 ; X64-NOBMI2-LABEL: clear_lowbits16_ic2_load:
972 ; X64-NOBMI2: # %bb.0:
973 ; X64-NOBMI2-NEXT: movzwl (%rdi), %eax
974 ; X64-NOBMI2-NEXT: movb $16, %cl
975 ; X64-NOBMI2-NEXT: subb %sil, %cl
976 ; X64-NOBMI2-NEXT: shrl %cl, %eax
977 ; X64-NOBMI2-NEXT: shll %cl, %eax
978 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
979 ; X64-NOBMI2-NEXT: retq
981 ; X64-BMI2-LABEL: clear_lowbits16_ic2_load:
983 ; X64-BMI2-NEXT: movzwl (%rdi), %eax
984 ; X64-BMI2-NEXT: movb $16, %cl
985 ; X64-BMI2-NEXT: subb %sil, %cl
986 ; X64-BMI2-NEXT: shrxl %ecx, %eax, %eax
987 ; X64-BMI2-NEXT: shlxl %ecx, %eax, %eax
988 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
989 ; X64-BMI2-NEXT: retq
990 %val = load i16, ptr %w
991 %numhighbits = sub i16 16, %numlowbits
992 %mask = shl i16 -1, %numhighbits
993 %masked = and i16 %mask, %val
997 define i16 @clear_lowbits16_ic3_load_indexzext(ptr %w, i8 %numlowbits) nounwind {
998 ; X86-NOBMI2-LABEL: clear_lowbits16_ic3_load_indexzext:
999 ; X86-NOBMI2: # %bb.0:
1000 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1001 ; X86-NOBMI2-NEXT: movzwl (%eax), %eax
1002 ; X86-NOBMI2-NEXT: movb $16, %cl
1003 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1004 ; X86-NOBMI2-NEXT: shrl %cl, %eax
1005 ; X86-NOBMI2-NEXT: shll %cl, %eax
1006 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
1007 ; X86-NOBMI2-NEXT: retl
1009 ; X86-BMI2-LABEL: clear_lowbits16_ic3_load_indexzext:
1010 ; X86-BMI2: # %bb.0:
1011 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1012 ; X86-BMI2-NEXT: movzwl (%eax), %eax
1013 ; X86-BMI2-NEXT: movb $16, %cl
1014 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1015 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
1016 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
1017 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
1018 ; X86-BMI2-NEXT: retl
1020 ; X64-NOBMI2-LABEL: clear_lowbits16_ic3_load_indexzext:
1021 ; X64-NOBMI2: # %bb.0:
1022 ; X64-NOBMI2-NEXT: movzwl (%rdi), %eax
1023 ; X64-NOBMI2-NEXT: movb $16, %cl
1024 ; X64-NOBMI2-NEXT: subb %sil, %cl
1025 ; X64-NOBMI2-NEXT: shrl %cl, %eax
1026 ; X64-NOBMI2-NEXT: shll %cl, %eax
1027 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
1028 ; X64-NOBMI2-NEXT: retq
1030 ; X64-BMI2-LABEL: clear_lowbits16_ic3_load_indexzext:
1031 ; X64-BMI2: # %bb.0:
1032 ; X64-BMI2-NEXT: movzwl (%rdi), %eax
1033 ; X64-BMI2-NEXT: movb $16, %cl
1034 ; X64-BMI2-NEXT: subb %sil, %cl
1035 ; X64-BMI2-NEXT: shrxl %ecx, %eax, %eax
1036 ; X64-BMI2-NEXT: shlxl %ecx, %eax, %eax
1037 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
1038 ; X64-BMI2-NEXT: retq
1039 %val = load i16, ptr %w
1040 %numhighbits = sub i8 16, %numlowbits
1041 %sh_prom = zext i8 %numhighbits to i16
1042 %mask = shl i16 -1, %sh_prom
1043 %masked = and i16 %mask, %val
1047 define i16 @clear_lowbits16_ic4_commutative(i16 %val, i16 %numlowbits) nounwind {
1048 ; X86-NOBMI2-LABEL: clear_lowbits16_ic4_commutative:
1049 ; X86-NOBMI2: # %bb.0:
1050 ; X86-NOBMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
1051 ; X86-NOBMI2-NEXT: movb $16, %cl
1052 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1053 ; X86-NOBMI2-NEXT: shrl %cl, %eax
1054 ; X86-NOBMI2-NEXT: shll %cl, %eax
1055 ; X86-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
1056 ; X86-NOBMI2-NEXT: retl
1058 ; X86-BMI2-LABEL: clear_lowbits16_ic4_commutative:
1059 ; X86-BMI2: # %bb.0:
1060 ; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax
1061 ; X86-BMI2-NEXT: movb $16, %cl
1062 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1063 ; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax
1064 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
1065 ; X86-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
1066 ; X86-BMI2-NEXT: retl
1068 ; X64-NOBMI2-LABEL: clear_lowbits16_ic4_commutative:
1069 ; X64-NOBMI2: # %bb.0:
1070 ; X64-NOBMI2-NEXT: movzwl %di, %eax
1071 ; X64-NOBMI2-NEXT: movb $16, %cl
1072 ; X64-NOBMI2-NEXT: subb %sil, %cl
1073 ; X64-NOBMI2-NEXT: shrl %cl, %eax
1074 ; X64-NOBMI2-NEXT: shll %cl, %eax
1075 ; X64-NOBMI2-NEXT: # kill: def $ax killed $ax killed $eax
1076 ; X64-NOBMI2-NEXT: retq
1078 ; X64-BMI2-LABEL: clear_lowbits16_ic4_commutative:
1079 ; X64-BMI2: # %bb.0:
1080 ; X64-BMI2-NEXT: movzwl %di, %eax
1081 ; X64-BMI2-NEXT: movb $16, %cl
1082 ; X64-BMI2-NEXT: subb %sil, %cl
1083 ; X64-BMI2-NEXT: shrxl %ecx, %eax, %eax
1084 ; X64-BMI2-NEXT: shlxl %ecx, %eax, %eax
1085 ; X64-BMI2-NEXT: # kill: def $ax killed $ax killed $eax
1086 ; X64-BMI2-NEXT: retq
1087 %numhighbits = sub i16 16, %numlowbits
1088 %mask = shl i16 -1, %numhighbits
1089 %masked = and i16 %val, %mask ; swapped order
1095 define i32 @clear_lowbits32_ic0(i32 %val, i32 %numlowbits) nounwind {
1096 ; X86-NOBMI2-LABEL: clear_lowbits32_ic0:
1097 ; X86-NOBMI2: # %bb.0:
1098 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1099 ; X86-NOBMI2-NEXT: xorl %ecx, %ecx
1100 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1101 ; X86-NOBMI2-NEXT: shrl %cl, %eax
1102 ; X86-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1103 ; X86-NOBMI2-NEXT: shll %cl, %eax
1104 ; X86-NOBMI2-NEXT: retl
1106 ; X86-BMI2-LABEL: clear_lowbits32_ic0:
1107 ; X86-BMI2: # %bb.0:
1108 ; X86-BMI2-NEXT: xorl %eax, %eax
1109 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %al
1110 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx
1111 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
1112 ; X86-BMI2-NEXT: retl
1114 ; X64-NOBMI2-LABEL: clear_lowbits32_ic0:
1115 ; X64-NOBMI2: # %bb.0:
1116 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1117 ; X64-NOBMI2-NEXT: movl %edi, %eax
1118 ; X64-NOBMI2-NEXT: negb %cl
1119 ; X64-NOBMI2-NEXT: shrl %cl, %eax
1120 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1121 ; X64-NOBMI2-NEXT: shll %cl, %eax
1122 ; X64-NOBMI2-NEXT: retq
1124 ; X64-BMI2-LABEL: clear_lowbits32_ic0:
1125 ; X64-BMI2: # %bb.0:
1126 ; X64-BMI2-NEXT: negb %sil
1127 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
1128 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
1129 ; X64-BMI2-NEXT: retq
1130 %numhighbits = sub i32 32, %numlowbits
1131 %mask = shl i32 -1, %numhighbits
1132 %masked = and i32 %mask, %val
1136 define i32 @clear_lowbits32_ic1_indexzext(i32 %val, i8 %numlowbits) nounwind {
1137 ; X86-NOBMI2-LABEL: clear_lowbits32_ic1_indexzext:
1138 ; X86-NOBMI2: # %bb.0:
1139 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1140 ; X86-NOBMI2-NEXT: xorl %ecx, %ecx
1141 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1142 ; X86-NOBMI2-NEXT: shrl %cl, %eax
1143 ; X86-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1144 ; X86-NOBMI2-NEXT: shll %cl, %eax
1145 ; X86-NOBMI2-NEXT: retl
1147 ; X86-BMI2-LABEL: clear_lowbits32_ic1_indexzext:
1148 ; X86-BMI2: # %bb.0:
1149 ; X86-BMI2-NEXT: xorl %eax, %eax
1150 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %al
1151 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx
1152 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
1153 ; X86-BMI2-NEXT: retl
1155 ; X64-NOBMI2-LABEL: clear_lowbits32_ic1_indexzext:
1156 ; X64-NOBMI2: # %bb.0:
1157 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1158 ; X64-NOBMI2-NEXT: movl %edi, %eax
1159 ; X64-NOBMI2-NEXT: negb %cl
1160 ; X64-NOBMI2-NEXT: shrl %cl, %eax
1161 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1162 ; X64-NOBMI2-NEXT: shll %cl, %eax
1163 ; X64-NOBMI2-NEXT: retq
1165 ; X64-BMI2-LABEL: clear_lowbits32_ic1_indexzext:
1166 ; X64-BMI2: # %bb.0:
1167 ; X64-BMI2-NEXT: negb %sil
1168 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
1169 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
1170 ; X64-BMI2-NEXT: retq
1171 %numhighbits = sub i8 32, %numlowbits
1172 %sh_prom = zext i8 %numhighbits to i32
1173 %mask = shl i32 -1, %sh_prom
1174 %masked = and i32 %mask, %val
1178 define i32 @clear_lowbits32_ic2_load(ptr %w, i32 %numlowbits) nounwind {
1179 ; X86-NOBMI2-LABEL: clear_lowbits32_ic2_load:
1180 ; X86-NOBMI2: # %bb.0:
1181 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1182 ; X86-NOBMI2-NEXT: movl (%eax), %eax
1183 ; X86-NOBMI2-NEXT: xorl %ecx, %ecx
1184 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1185 ; X86-NOBMI2-NEXT: shrl %cl, %eax
1186 ; X86-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1187 ; X86-NOBMI2-NEXT: shll %cl, %eax
1188 ; X86-NOBMI2-NEXT: retl
1190 ; X86-BMI2-LABEL: clear_lowbits32_ic2_load:
1191 ; X86-BMI2: # %bb.0:
1192 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1193 ; X86-BMI2-NEXT: xorl %ecx, %ecx
1194 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1195 ; X86-BMI2-NEXT: shrxl %ecx, (%eax), %eax
1196 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
1197 ; X86-BMI2-NEXT: retl
1199 ; X64-NOBMI2-LABEL: clear_lowbits32_ic2_load:
1200 ; X64-NOBMI2: # %bb.0:
1201 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1202 ; X64-NOBMI2-NEXT: movl (%rdi), %eax
1203 ; X64-NOBMI2-NEXT: negb %cl
1204 ; X64-NOBMI2-NEXT: shrl %cl, %eax
1205 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1206 ; X64-NOBMI2-NEXT: shll %cl, %eax
1207 ; X64-NOBMI2-NEXT: retq
1209 ; X64-BMI2-LABEL: clear_lowbits32_ic2_load:
1210 ; X64-BMI2: # %bb.0:
1211 ; X64-BMI2-NEXT: negb %sil
1212 ; X64-BMI2-NEXT: shrxl %esi, (%rdi), %eax
1213 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
1214 ; X64-BMI2-NEXT: retq
1215 %val = load i32, ptr %w
1216 %numhighbits = sub i32 32, %numlowbits
1217 %mask = shl i32 -1, %numhighbits
1218 %masked = and i32 %mask, %val
1222 define i32 @clear_lowbits32_ic3_load_indexzext(ptr %w, i8 %numlowbits) nounwind {
1223 ; X86-NOBMI2-LABEL: clear_lowbits32_ic3_load_indexzext:
1224 ; X86-NOBMI2: # %bb.0:
1225 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1226 ; X86-NOBMI2-NEXT: movl (%eax), %eax
1227 ; X86-NOBMI2-NEXT: xorl %ecx, %ecx
1228 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1229 ; X86-NOBMI2-NEXT: shrl %cl, %eax
1230 ; X86-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1231 ; X86-NOBMI2-NEXT: shll %cl, %eax
1232 ; X86-NOBMI2-NEXT: retl
1234 ; X86-BMI2-LABEL: clear_lowbits32_ic3_load_indexzext:
1235 ; X86-BMI2: # %bb.0:
1236 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1237 ; X86-BMI2-NEXT: xorl %ecx, %ecx
1238 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1239 ; X86-BMI2-NEXT: shrxl %ecx, (%eax), %eax
1240 ; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax
1241 ; X86-BMI2-NEXT: retl
1243 ; X64-NOBMI2-LABEL: clear_lowbits32_ic3_load_indexzext:
1244 ; X64-NOBMI2: # %bb.0:
1245 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1246 ; X64-NOBMI2-NEXT: movl (%rdi), %eax
1247 ; X64-NOBMI2-NEXT: negb %cl
1248 ; X64-NOBMI2-NEXT: shrl %cl, %eax
1249 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1250 ; X64-NOBMI2-NEXT: shll %cl, %eax
1251 ; X64-NOBMI2-NEXT: retq
1253 ; X64-BMI2-LABEL: clear_lowbits32_ic3_load_indexzext:
1254 ; X64-BMI2: # %bb.0:
1255 ; X64-BMI2-NEXT: negb %sil
1256 ; X64-BMI2-NEXT: shrxl %esi, (%rdi), %eax
1257 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
1258 ; X64-BMI2-NEXT: retq
1259 %val = load i32, ptr %w
1260 %numhighbits = sub i8 32, %numlowbits
1261 %sh_prom = zext i8 %numhighbits to i32
1262 %mask = shl i32 -1, %sh_prom
1263 %masked = and i32 %mask, %val
1267 define i32 @clear_lowbits32_ic4_commutative(i32 %val, i32 %numlowbits) nounwind {
1268 ; X86-NOBMI2-LABEL: clear_lowbits32_ic4_commutative:
1269 ; X86-NOBMI2: # %bb.0:
1270 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
1271 ; X86-NOBMI2-NEXT: xorl %ecx, %ecx
1272 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1273 ; X86-NOBMI2-NEXT: shrl %cl, %eax
1274 ; X86-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1275 ; X86-NOBMI2-NEXT: shll %cl, %eax
1276 ; X86-NOBMI2-NEXT: retl
1278 ; X86-BMI2-LABEL: clear_lowbits32_ic4_commutative:
1279 ; X86-BMI2: # %bb.0:
1280 ; X86-BMI2-NEXT: xorl %eax, %eax
1281 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %al
1282 ; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx
1283 ; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax
1284 ; X86-BMI2-NEXT: retl
1286 ; X64-NOBMI2-LABEL: clear_lowbits32_ic4_commutative:
1287 ; X64-NOBMI2: # %bb.0:
1288 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1289 ; X64-NOBMI2-NEXT: movl %edi, %eax
1290 ; X64-NOBMI2-NEXT: negb %cl
1291 ; X64-NOBMI2-NEXT: shrl %cl, %eax
1292 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1293 ; X64-NOBMI2-NEXT: shll %cl, %eax
1294 ; X64-NOBMI2-NEXT: retq
1296 ; X64-BMI2-LABEL: clear_lowbits32_ic4_commutative:
1297 ; X64-BMI2: # %bb.0:
1298 ; X64-BMI2-NEXT: negb %sil
1299 ; X64-BMI2-NEXT: shrxl %esi, %edi, %eax
1300 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
1301 ; X64-BMI2-NEXT: retq
1302 %numhighbits = sub i32 32, %numlowbits
1303 %mask = shl i32 -1, %numhighbits
1304 %masked = and i32 %val, %mask ; swapped order
1310 define i64 @clear_lowbits64_ic0(i64 %val, i64 %numlowbits) nounwind {
1311 ; X86-NOBMI2-LABEL: clear_lowbits64_ic0:
1312 ; X86-NOBMI2: # %bb.0:
1313 ; X86-NOBMI2-NEXT: movb $64, %cl
1314 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1315 ; X86-NOBMI2-NEXT: movl $-1, %edx
1316 ; X86-NOBMI2-NEXT: movl $-1, %eax
1317 ; X86-NOBMI2-NEXT: shll %cl, %eax
1318 ; X86-NOBMI2-NEXT: testb $32, %cl
1319 ; X86-NOBMI2-NEXT: je .LBB31_2
1320 ; X86-NOBMI2-NEXT: # %bb.1:
1321 ; X86-NOBMI2-NEXT: movl %eax, %edx
1322 ; X86-NOBMI2-NEXT: xorl %eax, %eax
1323 ; X86-NOBMI2-NEXT: .LBB31_2:
1324 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1325 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1326 ; X86-NOBMI2-NEXT: retl
1328 ; X86-BMI2-LABEL: clear_lowbits64_ic0:
1329 ; X86-BMI2: # %bb.0:
1330 ; X86-BMI2-NEXT: movb $64, %cl
1331 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1332 ; X86-BMI2-NEXT: movl $-1, %edx
1333 ; X86-BMI2-NEXT: shlxl %ecx, %edx, %eax
1334 ; X86-BMI2-NEXT: testb $32, %cl
1335 ; X86-BMI2-NEXT: je .LBB31_2
1336 ; X86-BMI2-NEXT: # %bb.1:
1337 ; X86-BMI2-NEXT: movl %eax, %edx
1338 ; X86-BMI2-NEXT: xorl %eax, %eax
1339 ; X86-BMI2-NEXT: .LBB31_2:
1340 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1341 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1342 ; X86-BMI2-NEXT: retl
1344 ; X64-NOBMI2-LABEL: clear_lowbits64_ic0:
1345 ; X64-NOBMI2: # %bb.0:
1346 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
1347 ; X64-NOBMI2-NEXT: movq %rdi, %rax
1348 ; X64-NOBMI2-NEXT: negb %cl
1349 ; X64-NOBMI2-NEXT: shrq %cl, %rax
1350 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
1351 ; X64-NOBMI2-NEXT: shlq %cl, %rax
1352 ; X64-NOBMI2-NEXT: retq
1354 ; X64-BMI2-LABEL: clear_lowbits64_ic0:
1355 ; X64-BMI2: # %bb.0:
1356 ; X64-BMI2-NEXT: negb %sil
1357 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
1358 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
1359 ; X64-BMI2-NEXT: retq
1360 %numhighbits = sub i64 64, %numlowbits
1361 %mask = shl i64 -1, %numhighbits
1362 %masked = and i64 %mask, %val
1366 define i64 @clear_lowbits64_ic1_indexzext(i64 %val, i8 %numlowbits) nounwind {
1367 ; X86-NOBMI2-LABEL: clear_lowbits64_ic1_indexzext:
1368 ; X86-NOBMI2: # %bb.0:
1369 ; X86-NOBMI2-NEXT: movb $64, %cl
1370 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1371 ; X86-NOBMI2-NEXT: movl $-1, %edx
1372 ; X86-NOBMI2-NEXT: movl $-1, %eax
1373 ; X86-NOBMI2-NEXT: shll %cl, %eax
1374 ; X86-NOBMI2-NEXT: testb $32, %cl
1375 ; X86-NOBMI2-NEXT: je .LBB32_2
1376 ; X86-NOBMI2-NEXT: # %bb.1:
1377 ; X86-NOBMI2-NEXT: movl %eax, %edx
1378 ; X86-NOBMI2-NEXT: xorl %eax, %eax
1379 ; X86-NOBMI2-NEXT: .LBB32_2:
1380 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1381 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1382 ; X86-NOBMI2-NEXT: retl
1384 ; X86-BMI2-LABEL: clear_lowbits64_ic1_indexzext:
1385 ; X86-BMI2: # %bb.0:
1386 ; X86-BMI2-NEXT: movb $64, %cl
1387 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1388 ; X86-BMI2-NEXT: movl $-1, %edx
1389 ; X86-BMI2-NEXT: shlxl %ecx, %edx, %eax
1390 ; X86-BMI2-NEXT: testb $32, %cl
1391 ; X86-BMI2-NEXT: je .LBB32_2
1392 ; X86-BMI2-NEXT: # %bb.1:
1393 ; X86-BMI2-NEXT: movl %eax, %edx
1394 ; X86-BMI2-NEXT: xorl %eax, %eax
1395 ; X86-BMI2-NEXT: .LBB32_2:
1396 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1397 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1398 ; X86-BMI2-NEXT: retl
1400 ; X64-NOBMI2-LABEL: clear_lowbits64_ic1_indexzext:
1401 ; X64-NOBMI2: # %bb.0:
1402 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1403 ; X64-NOBMI2-NEXT: movq %rdi, %rax
1404 ; X64-NOBMI2-NEXT: negb %cl
1405 ; X64-NOBMI2-NEXT: shrq %cl, %rax
1406 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1407 ; X64-NOBMI2-NEXT: shlq %cl, %rax
1408 ; X64-NOBMI2-NEXT: retq
1410 ; X64-BMI2-LABEL: clear_lowbits64_ic1_indexzext:
1411 ; X64-BMI2: # %bb.0:
1412 ; X64-BMI2-NEXT: # kill: def $esi killed $esi def $rsi
1413 ; X64-BMI2-NEXT: negb %sil
1414 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
1415 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
1416 ; X64-BMI2-NEXT: retq
1417 %numhighbits = sub i8 64, %numlowbits
1418 %sh_prom = zext i8 %numhighbits to i64
1419 %mask = shl i64 -1, %sh_prom
1420 %masked = and i64 %mask, %val
1424 define i64 @clear_lowbits64_ic2_load(ptr %w, i64 %numlowbits) nounwind {
1425 ; X86-NOBMI2-LABEL: clear_lowbits64_ic2_load:
1426 ; X86-NOBMI2: # %bb.0:
1427 ; X86-NOBMI2-NEXT: pushl %esi
1428 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
1429 ; X86-NOBMI2-NEXT: movb $64, %cl
1430 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1431 ; X86-NOBMI2-NEXT: movl $-1, %edx
1432 ; X86-NOBMI2-NEXT: movl $-1, %eax
1433 ; X86-NOBMI2-NEXT: shll %cl, %eax
1434 ; X86-NOBMI2-NEXT: testb $32, %cl
1435 ; X86-NOBMI2-NEXT: je .LBB33_2
1436 ; X86-NOBMI2-NEXT: # %bb.1:
1437 ; X86-NOBMI2-NEXT: movl %eax, %edx
1438 ; X86-NOBMI2-NEXT: xorl %eax, %eax
1439 ; X86-NOBMI2-NEXT: .LBB33_2:
1440 ; X86-NOBMI2-NEXT: andl (%esi), %eax
1441 ; X86-NOBMI2-NEXT: andl 4(%esi), %edx
1442 ; X86-NOBMI2-NEXT: popl %esi
1443 ; X86-NOBMI2-NEXT: retl
1445 ; X86-BMI2-LABEL: clear_lowbits64_ic2_load:
1446 ; X86-BMI2: # %bb.0:
1447 ; X86-BMI2-NEXT: pushl %ebx
1448 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
1449 ; X86-BMI2-NEXT: movb $64, %bl
1450 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %bl
1451 ; X86-BMI2-NEXT: movl $-1, %edx
1452 ; X86-BMI2-NEXT: shlxl %ebx, %edx, %eax
1453 ; X86-BMI2-NEXT: testb $32, %bl
1454 ; X86-BMI2-NEXT: je .LBB33_2
1455 ; X86-BMI2-NEXT: # %bb.1:
1456 ; X86-BMI2-NEXT: movl %eax, %edx
1457 ; X86-BMI2-NEXT: xorl %eax, %eax
1458 ; X86-BMI2-NEXT: .LBB33_2:
1459 ; X86-BMI2-NEXT: andl (%ecx), %eax
1460 ; X86-BMI2-NEXT: andl 4(%ecx), %edx
1461 ; X86-BMI2-NEXT: popl %ebx
1462 ; X86-BMI2-NEXT: retl
1464 ; X64-NOBMI2-LABEL: clear_lowbits64_ic2_load:
1465 ; X64-NOBMI2: # %bb.0:
1466 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
1467 ; X64-NOBMI2-NEXT: movq (%rdi), %rax
1468 ; X64-NOBMI2-NEXT: negb %cl
1469 ; X64-NOBMI2-NEXT: shrq %cl, %rax
1470 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
1471 ; X64-NOBMI2-NEXT: shlq %cl, %rax
1472 ; X64-NOBMI2-NEXT: retq
1474 ; X64-BMI2-LABEL: clear_lowbits64_ic2_load:
1475 ; X64-BMI2: # %bb.0:
1476 ; X64-BMI2-NEXT: negb %sil
1477 ; X64-BMI2-NEXT: shrxq %rsi, (%rdi), %rax
1478 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
1479 ; X64-BMI2-NEXT: retq
1480 %val = load i64, ptr %w
1481 %numhighbits = sub i64 64, %numlowbits
1482 %mask = shl i64 -1, %numhighbits
1483 %masked = and i64 %mask, %val
1487 define i64 @clear_lowbits64_ic3_load_indexzext(ptr %w, i8 %numlowbits) nounwind {
1488 ; X86-NOBMI2-LABEL: clear_lowbits64_ic3_load_indexzext:
1489 ; X86-NOBMI2: # %bb.0:
1490 ; X86-NOBMI2-NEXT: pushl %esi
1491 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
1492 ; X86-NOBMI2-NEXT: movb $64, %cl
1493 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1494 ; X86-NOBMI2-NEXT: movl $-1, %edx
1495 ; X86-NOBMI2-NEXT: movl $-1, %eax
1496 ; X86-NOBMI2-NEXT: shll %cl, %eax
1497 ; X86-NOBMI2-NEXT: testb $32, %cl
1498 ; X86-NOBMI2-NEXT: je .LBB34_2
1499 ; X86-NOBMI2-NEXT: # %bb.1:
1500 ; X86-NOBMI2-NEXT: movl %eax, %edx
1501 ; X86-NOBMI2-NEXT: xorl %eax, %eax
1502 ; X86-NOBMI2-NEXT: .LBB34_2:
1503 ; X86-NOBMI2-NEXT: andl (%esi), %eax
1504 ; X86-NOBMI2-NEXT: andl 4(%esi), %edx
1505 ; X86-NOBMI2-NEXT: popl %esi
1506 ; X86-NOBMI2-NEXT: retl
1508 ; X86-BMI2-LABEL: clear_lowbits64_ic3_load_indexzext:
1509 ; X86-BMI2: # %bb.0:
1510 ; X86-BMI2-NEXT: pushl %ebx
1511 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
1512 ; X86-BMI2-NEXT: movb $64, %bl
1513 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %bl
1514 ; X86-BMI2-NEXT: movl $-1, %edx
1515 ; X86-BMI2-NEXT: shlxl %ebx, %edx, %eax
1516 ; X86-BMI2-NEXT: testb $32, %bl
1517 ; X86-BMI2-NEXT: je .LBB34_2
1518 ; X86-BMI2-NEXT: # %bb.1:
1519 ; X86-BMI2-NEXT: movl %eax, %edx
1520 ; X86-BMI2-NEXT: xorl %eax, %eax
1521 ; X86-BMI2-NEXT: .LBB34_2:
1522 ; X86-BMI2-NEXT: andl (%ecx), %eax
1523 ; X86-BMI2-NEXT: andl 4(%ecx), %edx
1524 ; X86-BMI2-NEXT: popl %ebx
1525 ; X86-BMI2-NEXT: retl
1527 ; X64-NOBMI2-LABEL: clear_lowbits64_ic3_load_indexzext:
1528 ; X64-NOBMI2: # %bb.0:
1529 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1530 ; X64-NOBMI2-NEXT: movq (%rdi), %rax
1531 ; X64-NOBMI2-NEXT: negb %cl
1532 ; X64-NOBMI2-NEXT: shrq %cl, %rax
1533 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1534 ; X64-NOBMI2-NEXT: shlq %cl, %rax
1535 ; X64-NOBMI2-NEXT: retq
1537 ; X64-BMI2-LABEL: clear_lowbits64_ic3_load_indexzext:
1538 ; X64-BMI2: # %bb.0:
1539 ; X64-BMI2-NEXT: # kill: def $esi killed $esi def $rsi
1540 ; X64-BMI2-NEXT: negb %sil
1541 ; X64-BMI2-NEXT: shrxq %rsi, (%rdi), %rax
1542 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
1543 ; X64-BMI2-NEXT: retq
1544 %val = load i64, ptr %w
1545 %numhighbits = sub i8 64, %numlowbits
1546 %sh_prom = zext i8 %numhighbits to i64
1547 %mask = shl i64 -1, %sh_prom
1548 %masked = and i64 %mask, %val
1552 define i64 @clear_lowbits64_ic4_commutative(i64 %val, i64 %numlowbits) nounwind {
1553 ; X86-NOBMI2-LABEL: clear_lowbits64_ic4_commutative:
1554 ; X86-NOBMI2: # %bb.0:
1555 ; X86-NOBMI2-NEXT: movb $64, %cl
1556 ; X86-NOBMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1557 ; X86-NOBMI2-NEXT: movl $-1, %edx
1558 ; X86-NOBMI2-NEXT: movl $-1, %eax
1559 ; X86-NOBMI2-NEXT: shll %cl, %eax
1560 ; X86-NOBMI2-NEXT: testb $32, %cl
1561 ; X86-NOBMI2-NEXT: je .LBB35_2
1562 ; X86-NOBMI2-NEXT: # %bb.1:
1563 ; X86-NOBMI2-NEXT: movl %eax, %edx
1564 ; X86-NOBMI2-NEXT: xorl %eax, %eax
1565 ; X86-NOBMI2-NEXT: .LBB35_2:
1566 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1567 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1568 ; X86-NOBMI2-NEXT: retl
1570 ; X86-BMI2-LABEL: clear_lowbits64_ic4_commutative:
1571 ; X86-BMI2: # %bb.0:
1572 ; X86-BMI2-NEXT: movb $64, %cl
1573 ; X86-BMI2-NEXT: subb {{[0-9]+}}(%esp), %cl
1574 ; X86-BMI2-NEXT: movl $-1, %edx
1575 ; X86-BMI2-NEXT: shlxl %ecx, %edx, %eax
1576 ; X86-BMI2-NEXT: testb $32, %cl
1577 ; X86-BMI2-NEXT: je .LBB35_2
1578 ; X86-BMI2-NEXT: # %bb.1:
1579 ; X86-BMI2-NEXT: movl %eax, %edx
1580 ; X86-BMI2-NEXT: xorl %eax, %eax
1581 ; X86-BMI2-NEXT: .LBB35_2:
1582 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1583 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1584 ; X86-BMI2-NEXT: retl
1586 ; X64-NOBMI2-LABEL: clear_lowbits64_ic4_commutative:
1587 ; X64-NOBMI2: # %bb.0:
1588 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
1589 ; X64-NOBMI2-NEXT: movq %rdi, %rax
1590 ; X64-NOBMI2-NEXT: negb %cl
1591 ; X64-NOBMI2-NEXT: shrq %cl, %rax
1592 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
1593 ; X64-NOBMI2-NEXT: shlq %cl, %rax
1594 ; X64-NOBMI2-NEXT: retq
1596 ; X64-BMI2-LABEL: clear_lowbits64_ic4_commutative:
1597 ; X64-BMI2: # %bb.0:
1598 ; X64-BMI2-NEXT: negb %sil
1599 ; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax
1600 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
1601 ; X64-BMI2-NEXT: retq
1602 %numhighbits = sub i64 64, %numlowbits
1603 %mask = shl i64 -1, %numhighbits
1604 %masked = and i64 %val, %mask ; swapped order
1608 ; ---------------------------------------------------------------------------- ;
1610 ; ---------------------------------------------------------------------------- ;
1612 define i32 @oneuse32_c(i32 %val, i32 %numlowbits, ptr %escape) nounwind {
1613 ; X86-NOBMI2-LABEL: oneuse32_c:
1614 ; X86-NOBMI2: # %bb.0:
1615 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %edx
1616 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
1617 ; X86-NOBMI2-NEXT: movl $-1, %eax
1618 ; X86-NOBMI2-NEXT: shll %cl, %eax
1619 ; X86-NOBMI2-NEXT: movl %eax, (%edx)
1620 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1621 ; X86-NOBMI2-NEXT: retl
1623 ; X86-BMI2-LABEL: oneuse32_c:
1624 ; X86-BMI2: # %bb.0:
1625 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
1626 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax
1627 ; X86-BMI2-NEXT: movl $-1, %edx
1628 ; X86-BMI2-NEXT: shlxl %eax, %edx, %eax
1629 ; X86-BMI2-NEXT: movl %eax, (%ecx)
1630 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1631 ; X86-BMI2-NEXT: retl
1633 ; X64-NOBMI2-LABEL: oneuse32_c:
1634 ; X64-NOBMI2: # %bb.0:
1635 ; X64-NOBMI2-NEXT: movl %esi, %ecx
1636 ; X64-NOBMI2-NEXT: movl $-1, %eax
1637 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $ecx
1638 ; X64-NOBMI2-NEXT: shll %cl, %eax
1639 ; X64-NOBMI2-NEXT: movl %eax, (%rdx)
1640 ; X64-NOBMI2-NEXT: andl %edi, %eax
1641 ; X64-NOBMI2-NEXT: retq
1643 ; X64-BMI2-LABEL: oneuse32_c:
1644 ; X64-BMI2: # %bb.0:
1645 ; X64-BMI2-NEXT: movl $-1, %eax
1646 ; X64-BMI2-NEXT: shlxl %esi, %eax, %eax
1647 ; X64-BMI2-NEXT: movl %eax, (%rdx)
1648 ; X64-BMI2-NEXT: andl %edi, %eax
1649 ; X64-BMI2-NEXT: retq
1650 %mask = shl i32 -1, %numlowbits
1651 store i32 %mask, ptr %escape
1652 %masked = and i32 %mask, %val
1656 define i64 @oneuse64(i64 %val, i64 %numlowbits, ptr %escape) nounwind {
1657 ; X86-NOBMI2-LABEL: oneuse64:
1658 ; X86-NOBMI2: # %bb.0:
1659 ; X86-NOBMI2-NEXT: pushl %edi
1660 ; X86-NOBMI2-NEXT: pushl %esi
1661 ; X86-NOBMI2-NEXT: movl {{[0-9]+}}(%esp), %esi
1662 ; X86-NOBMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
1663 ; X86-NOBMI2-NEXT: movl $-1, %edx
1664 ; X86-NOBMI2-NEXT: movl $-1, %edi
1665 ; X86-NOBMI2-NEXT: shll %cl, %edi
1666 ; X86-NOBMI2-NEXT: xorl %eax, %eax
1667 ; X86-NOBMI2-NEXT: testb $32, %cl
1668 ; X86-NOBMI2-NEXT: jne .LBB37_1
1669 ; X86-NOBMI2-NEXT: # %bb.2:
1670 ; X86-NOBMI2-NEXT: movl %edi, %eax
1671 ; X86-NOBMI2-NEXT: jmp .LBB37_3
1672 ; X86-NOBMI2-NEXT: .LBB37_1:
1673 ; X86-NOBMI2-NEXT: movl %edi, %edx
1674 ; X86-NOBMI2-NEXT: .LBB37_3:
1675 ; X86-NOBMI2-NEXT: movl %edx, 4(%esi)
1676 ; X86-NOBMI2-NEXT: movl %eax, (%esi)
1677 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1678 ; X86-NOBMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1679 ; X86-NOBMI2-NEXT: popl %esi
1680 ; X86-NOBMI2-NEXT: popl %edi
1681 ; X86-NOBMI2-NEXT: retl
1683 ; X86-BMI2-LABEL: oneuse64:
1684 ; X86-BMI2: # %bb.0:
1685 ; X86-BMI2-NEXT: pushl %ebx
1686 ; X86-BMI2-NEXT: pushl %esi
1687 ; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
1688 ; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ebx
1689 ; X86-BMI2-NEXT: movl $-1, %edx
1690 ; X86-BMI2-NEXT: shlxl %ebx, %edx, %esi
1691 ; X86-BMI2-NEXT: xorl %eax, %eax
1692 ; X86-BMI2-NEXT: testb $32, %bl
1693 ; X86-BMI2-NEXT: jne .LBB37_1
1694 ; X86-BMI2-NEXT: # %bb.2:
1695 ; X86-BMI2-NEXT: movl %esi, %eax
1696 ; X86-BMI2-NEXT: jmp .LBB37_3
1697 ; X86-BMI2-NEXT: .LBB37_1:
1698 ; X86-BMI2-NEXT: movl %esi, %edx
1699 ; X86-BMI2-NEXT: .LBB37_3:
1700 ; X86-BMI2-NEXT: movl %edx, 4(%ecx)
1701 ; X86-BMI2-NEXT: movl %eax, (%ecx)
1702 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax
1703 ; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx
1704 ; X86-BMI2-NEXT: popl %esi
1705 ; X86-BMI2-NEXT: popl %ebx
1706 ; X86-BMI2-NEXT: retl
1708 ; X64-NOBMI2-LABEL: oneuse64:
1709 ; X64-NOBMI2: # %bb.0:
1710 ; X64-NOBMI2-NEXT: movq %rsi, %rcx
1711 ; X64-NOBMI2-NEXT: movq $-1, %rax
1712 ; X64-NOBMI2-NEXT: # kill: def $cl killed $cl killed $rcx
1713 ; X64-NOBMI2-NEXT: shlq %cl, %rax
1714 ; X64-NOBMI2-NEXT: movq %rax, (%rdx)
1715 ; X64-NOBMI2-NEXT: andq %rdi, %rax
1716 ; X64-NOBMI2-NEXT: retq
1718 ; X64-BMI2-LABEL: oneuse64:
1719 ; X64-BMI2: # %bb.0:
1720 ; X64-BMI2-NEXT: movq $-1, %rax
1721 ; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax
1722 ; X64-BMI2-NEXT: movq %rax, (%rdx)
1723 ; X64-BMI2-NEXT: andq %rdi, %rax
1724 ; X64-BMI2-NEXT: retq
1725 %mask = shl i64 -1, %numlowbits
1726 store i64 %mask, ptr %escape
1727 %masked = and i64 %mask, %val