1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=-popcnt | FileCheck %s --check-prefix=X86-NOPOPCNT
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-popcnt | FileCheck %s --check-prefix=X64-NOPOPCNT
4 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+popcnt | FileCheck %s --check-prefix=X86-POPCNT
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+popcnt | FileCheck %s --check-prefix=X64-POPCNT
7 define i4 @parity_4(i4 %x) {
8 ; X86-NOPOPCNT-LABEL: parity_4:
9 ; X86-NOPOPCNT: # %bb.0:
10 ; X86-NOPOPCNT-NEXT: testb $15, {{[0-9]+}}(%esp)
11 ; X86-NOPOPCNT-NEXT: setnp %al
12 ; X86-NOPOPCNT-NEXT: retl
14 ; X64-NOPOPCNT-LABEL: parity_4:
15 ; X64-NOPOPCNT: # %bb.0:
16 ; X64-NOPOPCNT-NEXT: testb $15, %dil
17 ; X64-NOPOPCNT-NEXT: setnp %al
18 ; X64-NOPOPCNT-NEXT: retq
20 ; X86-POPCNT-LABEL: parity_4:
21 ; X86-POPCNT: # %bb.0:
22 ; X86-POPCNT-NEXT: testb $15, {{[0-9]+}}(%esp)
23 ; X86-POPCNT-NEXT: setnp %al
24 ; X86-POPCNT-NEXT: retl
26 ; X64-POPCNT-LABEL: parity_4:
27 ; X64-POPCNT: # %bb.0:
28 ; X64-POPCNT-NEXT: testb $15, %dil
29 ; X64-POPCNT-NEXT: setnp %al
30 ; X64-POPCNT-NEXT: retq
31 %1 = tail call i4 @llvm.ctpop.i4(i4 %x)
36 define i8 @parity_8(i8 %x) {
37 ; X86-NOPOPCNT-LABEL: parity_8:
38 ; X86-NOPOPCNT: # %bb.0:
39 ; X86-NOPOPCNT-NEXT: cmpb $0, {{[0-9]+}}(%esp)
40 ; X86-NOPOPCNT-NEXT: setnp %al
41 ; X86-NOPOPCNT-NEXT: retl
43 ; X64-NOPOPCNT-LABEL: parity_8:
44 ; X64-NOPOPCNT: # %bb.0:
45 ; X64-NOPOPCNT-NEXT: testb %dil, %dil
46 ; X64-NOPOPCNT-NEXT: setnp %al
47 ; X64-NOPOPCNT-NEXT: retq
49 ; X86-POPCNT-LABEL: parity_8:
50 ; X86-POPCNT: # %bb.0:
51 ; X86-POPCNT-NEXT: cmpb $0, {{[0-9]+}}(%esp)
52 ; X86-POPCNT-NEXT: setnp %al
53 ; X86-POPCNT-NEXT: retl
55 ; X64-POPCNT-LABEL: parity_8:
56 ; X64-POPCNT: # %bb.0:
57 ; X64-POPCNT-NEXT: testb %dil, %dil
58 ; X64-POPCNT-NEXT: setnp %al
59 ; X64-POPCNT-NEXT: retq
60 %1 = tail call i8 @llvm.ctpop.i8(i8 %x)
65 define i16 @parity_16(i16 %x) {
66 ; X86-NOPOPCNT-LABEL: parity_16:
67 ; X86-NOPOPCNT: # %bb.0:
68 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %ecx
69 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
70 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
71 ; X86-NOPOPCNT-NEXT: setnp %al
72 ; X86-NOPOPCNT-NEXT: # kill: def $ax killed $ax killed $eax
73 ; X86-NOPOPCNT-NEXT: retl
75 ; X64-NOPOPCNT-LABEL: parity_16:
76 ; X64-NOPOPCNT: # %bb.0:
77 ; X64-NOPOPCNT-NEXT: movl %edi, %ecx
78 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
79 ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
80 ; X64-NOPOPCNT-NEXT: setnp %al
81 ; X64-NOPOPCNT-NEXT: # kill: def $ax killed $ax killed $eax
82 ; X64-NOPOPCNT-NEXT: retq
84 ; X86-POPCNT-LABEL: parity_16:
85 ; X86-POPCNT: # %bb.0:
86 ; X86-POPCNT-NEXT: popcntw {{[0-9]+}}(%esp), %ax
87 ; X86-POPCNT-NEXT: andl $1, %eax
88 ; X86-POPCNT-NEXT: # kill: def $ax killed $ax killed $eax
89 ; X86-POPCNT-NEXT: retl
91 ; X64-POPCNT-LABEL: parity_16:
92 ; X64-POPCNT: # %bb.0:
93 ; X64-POPCNT-NEXT: popcntw %di, %ax
94 ; X64-POPCNT-NEXT: andl $1, %eax
95 ; X64-POPCNT-NEXT: # kill: def $ax killed $ax killed $eax
96 ; X64-POPCNT-NEXT: retq
97 %1 = tail call i16 @llvm.ctpop.i16(i16 %x)
102 define i16 @parity_16_load(i16* %x) {
103 ; X86-NOPOPCNT-LABEL: parity_16_load:
104 ; X86-NOPOPCNT: # %bb.0:
105 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
106 ; X86-NOPOPCNT-NEXT: movzwl (%eax), %ecx
107 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
108 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
109 ; X86-NOPOPCNT-NEXT: setnp %al
110 ; X86-NOPOPCNT-NEXT: # kill: def $ax killed $ax killed $eax
111 ; X86-NOPOPCNT-NEXT: retl
113 ; X64-NOPOPCNT-LABEL: parity_16_load:
114 ; X64-NOPOPCNT: # %bb.0:
115 ; X64-NOPOPCNT-NEXT: movzwl (%rdi), %ecx
116 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
117 ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
118 ; X64-NOPOPCNT-NEXT: setnp %al
119 ; X64-NOPOPCNT-NEXT: # kill: def $ax killed $ax killed $eax
120 ; X64-NOPOPCNT-NEXT: retq
122 ; X86-POPCNT-LABEL: parity_16_load:
123 ; X86-POPCNT: # %bb.0:
124 ; X86-POPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
125 ; X86-POPCNT-NEXT: popcntw (%eax), %ax
126 ; X86-POPCNT-NEXT: andl $1, %eax
127 ; X86-POPCNT-NEXT: # kill: def $ax killed $ax killed $eax
128 ; X86-POPCNT-NEXT: retl
130 ; X64-POPCNT-LABEL: parity_16_load:
131 ; X64-POPCNT: # %bb.0:
132 ; X64-POPCNT-NEXT: popcntw (%rdi), %ax
133 ; X64-POPCNT-NEXT: andl $1, %eax
134 ; X64-POPCNT-NEXT: # kill: def $ax killed $ax killed $eax
135 ; X64-POPCNT-NEXT: retq
136 %1 = load i16, i16* %x
137 %2 = tail call i16 @llvm.ctpop.i16(i16 %1)
142 define i17 @parity_17(i17 %x) {
143 ; X86-NOPOPCNT-LABEL: parity_17:
144 ; X86-NOPOPCNT: # %bb.0:
145 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %ecx
146 ; X86-NOPOPCNT-NEXT: movl %ecx, %eax
147 ; X86-NOPOPCNT-NEXT: andl $131071, %eax # imm = 0x1FFFF
148 ; X86-NOPOPCNT-NEXT: movl %eax, %edx
149 ; X86-NOPOPCNT-NEXT: shrl $16, %edx
150 ; X86-NOPOPCNT-NEXT: xorl %eax, %edx
151 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
152 ; X86-NOPOPCNT-NEXT: xorb %dl, %ch
153 ; X86-NOPOPCNT-NEXT: setnp %al
154 ; X86-NOPOPCNT-NEXT: retl
156 ; X64-NOPOPCNT-LABEL: parity_17:
157 ; X64-NOPOPCNT: # %bb.0:
158 ; X64-NOPOPCNT-NEXT: movl %edi, %eax
159 ; X64-NOPOPCNT-NEXT: andl $131071, %eax # imm = 0x1FFFF
160 ; X64-NOPOPCNT-NEXT: movl %eax, %ecx
161 ; X64-NOPOPCNT-NEXT: shrl $16, %ecx
162 ; X64-NOPOPCNT-NEXT: xorl %eax, %ecx
163 ; X64-NOPOPCNT-NEXT: shrl $8, %edi
164 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
165 ; X64-NOPOPCNT-NEXT: xorb %cl, %dil
166 ; X64-NOPOPCNT-NEXT: setnp %al
167 ; X64-NOPOPCNT-NEXT: retq
169 ; X86-POPCNT-LABEL: parity_17:
170 ; X86-POPCNT: # %bb.0:
171 ; X86-POPCNT-NEXT: movl $131071, %eax # imm = 0x1FFFF
172 ; X86-POPCNT-NEXT: andl {{[0-9]+}}(%esp), %eax
173 ; X86-POPCNT-NEXT: popcntl %eax, %eax
174 ; X86-POPCNT-NEXT: andl $1, %eax
175 ; X86-POPCNT-NEXT: retl
177 ; X64-POPCNT-LABEL: parity_17:
178 ; X64-POPCNT: # %bb.0:
179 ; X64-POPCNT-NEXT: andl $131071, %edi # imm = 0x1FFFF
180 ; X64-POPCNT-NEXT: popcntl %edi, %eax
181 ; X64-POPCNT-NEXT: andl $1, %eax
182 ; X64-POPCNT-NEXT: retq
183 %1 = tail call i17 @llvm.ctpop.i17(i17 %x)
188 define i32 @parity_32(i32 %x) {
189 ; X86-NOPOPCNT-LABEL: parity_32:
190 ; X86-NOPOPCNT: # %bb.0:
191 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
192 ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
193 ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
194 ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
195 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
196 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
197 ; X86-NOPOPCNT-NEXT: setnp %al
198 ; X86-NOPOPCNT-NEXT: retl
200 ; X64-NOPOPCNT-LABEL: parity_32:
201 ; X64-NOPOPCNT: # %bb.0:
202 ; X64-NOPOPCNT-NEXT: movl %edi, %ecx
203 ; X64-NOPOPCNT-NEXT: shrl $16, %ecx
204 ; X64-NOPOPCNT-NEXT: xorl %edi, %ecx
205 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
206 ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
207 ; X64-NOPOPCNT-NEXT: setnp %al
208 ; X64-NOPOPCNT-NEXT: retq
210 ; X86-POPCNT-LABEL: parity_32:
211 ; X86-POPCNT: # %bb.0:
212 ; X86-POPCNT-NEXT: popcntl {{[0-9]+}}(%esp), %eax
213 ; X86-POPCNT-NEXT: andl $1, %eax
214 ; X86-POPCNT-NEXT: retl
216 ; X64-POPCNT-LABEL: parity_32:
217 ; X64-POPCNT: # %bb.0:
218 ; X64-POPCNT-NEXT: popcntl %edi, %eax
219 ; X64-POPCNT-NEXT: andl $1, %eax
220 ; X64-POPCNT-NEXT: retq
221 %1 = tail call i32 @llvm.ctpop.i32(i32 %x)
226 define i64 @parity_64(i64 %x) {
227 ; X86-NOPOPCNT-LABEL: parity_64:
228 ; X86-NOPOPCNT: # %bb.0:
229 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
230 ; X86-NOPOPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
231 ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
232 ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
233 ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
234 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
235 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
236 ; X86-NOPOPCNT-NEXT: setnp %al
237 ; X86-NOPOPCNT-NEXT: xorl %edx, %edx
238 ; X86-NOPOPCNT-NEXT: retl
240 ; X64-NOPOPCNT-LABEL: parity_64:
241 ; X64-NOPOPCNT: # %bb.0:
242 ; X64-NOPOPCNT-NEXT: movq %rdi, %rax
243 ; X64-NOPOPCNT-NEXT: shrq $32, %rax
244 ; X64-NOPOPCNT-NEXT: xorl %edi, %eax
245 ; X64-NOPOPCNT-NEXT: movl %eax, %ecx
246 ; X64-NOPOPCNT-NEXT: shrl $16, %ecx
247 ; X64-NOPOPCNT-NEXT: xorl %eax, %ecx
248 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
249 ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
250 ; X64-NOPOPCNT-NEXT: setnp %al
251 ; X64-NOPOPCNT-NEXT: retq
253 ; X86-POPCNT-LABEL: parity_64:
254 ; X86-POPCNT: # %bb.0:
255 ; X86-POPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
256 ; X86-POPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
257 ; X86-POPCNT-NEXT: popcntl %eax, %eax
258 ; X86-POPCNT-NEXT: andl $1, %eax
259 ; X86-POPCNT-NEXT: xorl %edx, %edx
260 ; X86-POPCNT-NEXT: retl
262 ; X64-POPCNT-LABEL: parity_64:
263 ; X64-POPCNT: # %bb.0:
264 ; X64-POPCNT-NEXT: popcntq %rdi, %rax
265 ; X64-POPCNT-NEXT: andl $1, %eax
266 ; X64-POPCNT-NEXT: retq
267 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
272 define i32 @parity_64_trunc(i64 %x) {
273 ; X86-NOPOPCNT-LABEL: parity_64_trunc:
274 ; X86-NOPOPCNT: # %bb.0:
275 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
276 ; X86-NOPOPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
277 ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
278 ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
279 ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
280 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
281 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
282 ; X86-NOPOPCNT-NEXT: setnp %al
283 ; X86-NOPOPCNT-NEXT: retl
285 ; X64-NOPOPCNT-LABEL: parity_64_trunc:
286 ; X64-NOPOPCNT: # %bb.0:
287 ; X64-NOPOPCNT-NEXT: movq %rdi, %rax
288 ; X64-NOPOPCNT-NEXT: shrq $32, %rax
289 ; X64-NOPOPCNT-NEXT: xorl %edi, %eax
290 ; X64-NOPOPCNT-NEXT: movl %eax, %ecx
291 ; X64-NOPOPCNT-NEXT: shrl $16, %ecx
292 ; X64-NOPOPCNT-NEXT: xorl %eax, %ecx
293 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
294 ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
295 ; X64-NOPOPCNT-NEXT: setnp %al
296 ; X64-NOPOPCNT-NEXT: retq
298 ; X86-POPCNT-LABEL: parity_64_trunc:
299 ; X86-POPCNT: # %bb.0:
300 ; X86-POPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
301 ; X86-POPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
302 ; X86-POPCNT-NEXT: popcntl %eax, %eax
303 ; X86-POPCNT-NEXT: andl $1, %eax
304 ; X86-POPCNT-NEXT: retl
306 ; X64-POPCNT-LABEL: parity_64_trunc:
307 ; X64-POPCNT: # %bb.0:
308 ; X64-POPCNT-NEXT: popcntq %rdi, %rax
309 ; X64-POPCNT-NEXT: andl $1, %eax
310 ; X64-POPCNT-NEXT: # kill: def $eax killed $eax killed $rax
311 ; X64-POPCNT-NEXT: retq
312 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
313 %2 = trunc i64 %1 to i32
318 define i8 @parity_32_trunc(i32 %x) {
319 ; X86-NOPOPCNT-LABEL: parity_32_trunc:
320 ; X86-NOPOPCNT: # %bb.0:
321 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
322 ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
323 ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
324 ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
325 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
326 ; X86-NOPOPCNT-NEXT: setnp %al
327 ; X86-NOPOPCNT-NEXT: retl
329 ; X64-NOPOPCNT-LABEL: parity_32_trunc:
330 ; X64-NOPOPCNT: # %bb.0:
331 ; X64-NOPOPCNT-NEXT: movl %edi, %eax
332 ; X64-NOPOPCNT-NEXT: shrl $16, %eax
333 ; X64-NOPOPCNT-NEXT: xorl %edi, %eax
334 ; X64-NOPOPCNT-NEXT: xorb %ah, %al
335 ; X64-NOPOPCNT-NEXT: setnp %al
336 ; X64-NOPOPCNT-NEXT: retq
338 ; X86-POPCNT-LABEL: parity_32_trunc:
339 ; X86-POPCNT: # %bb.0:
340 ; X86-POPCNT-NEXT: popcntl {{[0-9]+}}(%esp), %eax
341 ; X86-POPCNT-NEXT: andl $1, %eax
342 ; X86-POPCNT-NEXT: # kill: def $al killed $al killed $eax
343 ; X86-POPCNT-NEXT: retl
345 ; X64-POPCNT-LABEL: parity_32_trunc:
346 ; X64-POPCNT: # %bb.0:
347 ; X64-POPCNT-NEXT: popcntl %edi, %eax
348 ; X64-POPCNT-NEXT: andl $1, %eax
349 ; X64-POPCNT-NEXT: # kill: def $al killed $al killed $eax
350 ; X64-POPCNT-NEXT: retq
351 %1 = tail call i32 @llvm.ctpop.i32(i32 %x)
352 %2 = trunc i32 %1 to i8
357 define i32 @parity_8_zext(i8 %x) {
358 ; X86-NOPOPCNT-LABEL: parity_8_zext:
359 ; X86-NOPOPCNT: # %bb.0:
360 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
361 ; X86-NOPOPCNT-NEXT: cmpb $0, {{[0-9]+}}(%esp)
362 ; X86-NOPOPCNT-NEXT: setnp %al
363 ; X86-NOPOPCNT-NEXT: retl
365 ; X64-NOPOPCNT-LABEL: parity_8_zext:
366 ; X64-NOPOPCNT: # %bb.0:
367 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
368 ; X64-NOPOPCNT-NEXT: testb %dil, %dil
369 ; X64-NOPOPCNT-NEXT: setnp %al
370 ; X64-NOPOPCNT-NEXT: retq
372 ; X86-POPCNT-LABEL: parity_8_zext:
373 ; X86-POPCNT: # %bb.0:
374 ; X86-POPCNT-NEXT: movzbl {{[0-9]+}}(%esp), %eax
375 ; X86-POPCNT-NEXT: popcntl %eax, %eax
376 ; X86-POPCNT-NEXT: andl $1, %eax
377 ; X86-POPCNT-NEXT: retl
379 ; X64-POPCNT-LABEL: parity_8_zext:
380 ; X64-POPCNT: # %bb.0:
381 ; X64-POPCNT-NEXT: movzbl %dil, %eax
382 ; X64-POPCNT-NEXT: popcntl %eax, %eax
383 ; X64-POPCNT-NEXT: andl $1, %eax
384 ; X64-POPCNT-NEXT: retq
385 %a = zext i8 %x to i32
386 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
391 define i32 @parity_8_mask(i32 %x) {
392 ; X86-NOPOPCNT-LABEL: parity_8_mask:
393 ; X86-NOPOPCNT: # %bb.0:
394 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
395 ; X86-NOPOPCNT-NEXT: cmpb $0, {{[0-9]+}}(%esp)
396 ; X86-NOPOPCNT-NEXT: setnp %al
397 ; X86-NOPOPCNT-NEXT: retl
399 ; X64-NOPOPCNT-LABEL: parity_8_mask:
400 ; X64-NOPOPCNT: # %bb.0:
401 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
402 ; X64-NOPOPCNT-NEXT: testb %dil, %dil
403 ; X64-NOPOPCNT-NEXT: setnp %al
404 ; X64-NOPOPCNT-NEXT: retq
406 ; X86-POPCNT-LABEL: parity_8_mask:
407 ; X86-POPCNT: # %bb.0:
408 ; X86-POPCNT-NEXT: movzbl {{[0-9]+}}(%esp), %eax
409 ; X86-POPCNT-NEXT: popcntl %eax, %eax
410 ; X86-POPCNT-NEXT: andl $1, %eax
411 ; X86-POPCNT-NEXT: retl
413 ; X64-POPCNT-LABEL: parity_8_mask:
414 ; X64-POPCNT: # %bb.0:
415 ; X64-POPCNT-NEXT: movzbl %dil, %eax
416 ; X64-POPCNT-NEXT: popcntl %eax, %eax
417 ; X64-POPCNT-NEXT: andl $1, %eax
418 ; X64-POPCNT-NEXT: retq
420 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
425 define i32 @parity_32_shift(i32 %0) {
426 ; X86-NOPOPCNT-LABEL: parity_32_shift:
427 ; X86-NOPOPCNT: # %bb.0:
428 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
429 ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
430 ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
431 ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
432 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
433 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
434 ; X86-NOPOPCNT-NEXT: setnp %al
435 ; X86-NOPOPCNT-NEXT: addl %eax, %eax
436 ; X86-NOPOPCNT-NEXT: retl
438 ; X64-NOPOPCNT-LABEL: parity_32_shift:
439 ; X64-NOPOPCNT: # %bb.0:
440 ; X64-NOPOPCNT-NEXT: movl %edi, %ecx
441 ; X64-NOPOPCNT-NEXT: shrl $16, %ecx
442 ; X64-NOPOPCNT-NEXT: xorl %edi, %ecx
443 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
444 ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
445 ; X64-NOPOPCNT-NEXT: setnp %al
446 ; X64-NOPOPCNT-NEXT: addl %eax, %eax
447 ; X64-NOPOPCNT-NEXT: retq
449 ; X86-POPCNT-LABEL: parity_32_shift:
450 ; X86-POPCNT: # %bb.0:
451 ; X86-POPCNT-NEXT: popcntl {{[0-9]+}}(%esp), %eax
452 ; X86-POPCNT-NEXT: andl $1, %eax
453 ; X86-POPCNT-NEXT: addl %eax, %eax
454 ; X86-POPCNT-NEXT: retl
456 ; X64-POPCNT-LABEL: parity_32_shift:
457 ; X64-POPCNT: # %bb.0:
458 ; X64-POPCNT-NEXT: popcntl %edi, %eax
459 ; X64-POPCNT-NEXT: andl $1, %eax
460 ; X64-POPCNT-NEXT: addl %eax, %eax
461 ; X64-POPCNT-NEXT: retq
462 %2 = tail call i32 @llvm.ctpop.i32(i32 %0)
463 %3 = shl nuw nsw i32 %2, 1
468 define i64 @parity_64_shift(i64 %0) {
469 ; X86-NOPOPCNT-LABEL: parity_64_shift:
470 ; X86-NOPOPCNT: # %bb.0:
471 ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
472 ; X86-NOPOPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
473 ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
474 ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
475 ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
476 ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
477 ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
478 ; X86-NOPOPCNT-NEXT: setnp %al
479 ; X86-NOPOPCNT-NEXT: addl %eax, %eax
480 ; X86-NOPOPCNT-NEXT: xorl %edx, %edx
481 ; X86-NOPOPCNT-NEXT: retl
483 ; X64-NOPOPCNT-LABEL: parity_64_shift:
484 ; X64-NOPOPCNT: # %bb.0:
485 ; X64-NOPOPCNT-NEXT: movq %rdi, %rax
486 ; X64-NOPOPCNT-NEXT: shrq $32, %rax
487 ; X64-NOPOPCNT-NEXT: xorl %edi, %eax
488 ; X64-NOPOPCNT-NEXT: movl %eax, %ecx
489 ; X64-NOPOPCNT-NEXT: shrl $16, %ecx
490 ; X64-NOPOPCNT-NEXT: xorl %eax, %ecx
491 ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
492 ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
493 ; X64-NOPOPCNT-NEXT: setnp %al
494 ; X64-NOPOPCNT-NEXT: addq %rax, %rax
495 ; X64-NOPOPCNT-NEXT: retq
497 ; X86-POPCNT-LABEL: parity_64_shift:
498 ; X86-POPCNT: # %bb.0:
499 ; X86-POPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
500 ; X86-POPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
501 ; X86-POPCNT-NEXT: popcntl %eax, %eax
502 ; X86-POPCNT-NEXT: andl $1, %eax
503 ; X86-POPCNT-NEXT: addl %eax, %eax
504 ; X86-POPCNT-NEXT: xorl %edx, %edx
505 ; X86-POPCNT-NEXT: retl
507 ; X64-POPCNT-LABEL: parity_64_shift:
508 ; X64-POPCNT: # %bb.0:
509 ; X64-POPCNT-NEXT: popcntq %rdi, %rax
510 ; X64-POPCNT-NEXT: andl $1, %eax
511 ; X64-POPCNT-NEXT: addq %rax, %rax
512 ; X64-POPCNT-NEXT: retq
513 %2 = tail call i64 @llvm.ctpop.i64(i64 %0)
514 %3 = shl nuw nsw i64 %2, 1
519 declare i4 @llvm.ctpop.i4(i4 %x)
520 declare i8 @llvm.ctpop.i8(i8 %x)
521 declare i16 @llvm.ctpop.i16(i16 %x)
522 declare i17 @llvm.ctpop.i17(i17 %x)
523 declare i32 @llvm.ctpop.i32(i32 %x)
524 declare i64 @llvm.ctpop.i64(i64 %x)