@@ -404,64 +404,39 @@ define i16 @parity_16_mask15(i16 %x) {
404
404
define i16 @parity_16_shift (i16 %0 ) {
405
405
; X86-NOPOPCNT-LABEL: parity_16_shift:
406
406
; X86-NOPOPCNT: # %bb.0:
407
- ; X86-NOPOPCNT-NEXT: movzwl {{[0-9]+}}(%esp), %eax
408
- ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
409
- ; X86-NOPOPCNT-NEXT: shrl %ecx
410
- ; X86-NOPOPCNT-NEXT: andl $21845, %ecx # imm = 0x5555
411
- ; X86-NOPOPCNT-NEXT: subl %ecx, %eax
412
- ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
413
- ; X86-NOPOPCNT-NEXT: andl $13107, %ecx # imm = 0x3333
414
- ; X86-NOPOPCNT-NEXT: shrl $2, %eax
415
- ; X86-NOPOPCNT-NEXT: andl $13107, %eax # imm = 0x3333
416
- ; X86-NOPOPCNT-NEXT: addl %ecx, %eax
417
- ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
418
- ; X86-NOPOPCNT-NEXT: shrl $4, %ecx
419
- ; X86-NOPOPCNT-NEXT: addl %eax, %ecx
420
- ; X86-NOPOPCNT-NEXT: movl %ecx, %eax
421
- ; X86-NOPOPCNT-NEXT: shrl $8, %eax
422
- ; X86-NOPOPCNT-NEXT: addl %ecx, %eax
407
+ ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %ecx
408
+ ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
409
+ ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
410
+ ; X86-NOPOPCNT-NEXT: setnp %al
423
411
; X86-NOPOPCNT-NEXT: addl %eax, %eax
424
- ; X86-NOPOPCNT-NEXT: andl $2, %eax
425
412
; X86-NOPOPCNT-NEXT: # kill: def $ax killed $ax killed $eax
426
413
; X86-NOPOPCNT-NEXT: retl
427
414
;
428
415
; X64-NOPOPCNT-LABEL: parity_16_shift:
429
416
; X64-NOPOPCNT: # %bb.0:
430
- ; X64-NOPOPCNT-NEXT: movl %edi, %eax
431
- ; X64-NOPOPCNT-NEXT: shrl %eax
432
- ; X64-NOPOPCNT-NEXT: andl $21845, %eax # imm = 0x5555
433
- ; X64-NOPOPCNT-NEXT: subl %eax, %edi
434
- ; X64-NOPOPCNT-NEXT: movl %edi, %eax
435
- ; X64-NOPOPCNT-NEXT: andl $13107, %eax # imm = 0x3333
436
- ; X64-NOPOPCNT-NEXT: shrl $2, %edi
437
- ; X64-NOPOPCNT-NEXT: andl $13107, %edi # imm = 0x3333
438
- ; X64-NOPOPCNT-NEXT: addl %edi, %eax
439
- ; X64-NOPOPCNT-NEXT: movl %eax, %ecx
440
- ; X64-NOPOPCNT-NEXT: shrl $4, %ecx
441
- ; X64-NOPOPCNT-NEXT: addl %eax, %ecx
442
- ; X64-NOPOPCNT-NEXT: movl %ecx, %eax
443
- ; X64-NOPOPCNT-NEXT: shrl $8, %eax
444
- ; X64-NOPOPCNT-NEXT: addl %ecx, %eax
417
+ ; X64-NOPOPCNT-NEXT: movl %edi, %ecx
418
+ ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
419
+ ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
420
+ ; X64-NOPOPCNT-NEXT: setnp %al
445
421
; X64-NOPOPCNT-NEXT: addl %eax, %eax
446
- ; X64-NOPOPCNT-NEXT: andl $2, %eax
447
422
; X64-NOPOPCNT-NEXT: # kill: def $ax killed $ax killed $eax
448
423
; X64-NOPOPCNT-NEXT: retq
449
424
;
450
425
; X86-POPCNT-LABEL: parity_16_shift:
451
426
; X86-POPCNT: # %bb.0:
452
427
; X86-POPCNT-NEXT: movzwl {{[0-9]+}}(%esp), %eax
453
428
; X86-POPCNT-NEXT: popcntl %eax, %eax
429
+ ; X86-POPCNT-NEXT: andl $1, %eax
454
430
; X86-POPCNT-NEXT: addl %eax, %eax
455
- ; X86-POPCNT-NEXT: andl $2, %eax
456
431
; X86-POPCNT-NEXT: # kill: def $ax killed $ax killed $eax
457
432
; X86-POPCNT-NEXT: retl
458
433
;
459
434
; X64-POPCNT-LABEL: parity_16_shift:
460
435
; X64-POPCNT: # %bb.0:
461
436
; X64-POPCNT-NEXT: movzwl %di, %eax
462
437
; X64-POPCNT-NEXT: popcntl %eax, %eax
438
+ ; X64-POPCNT-NEXT: andl $1, %eax
463
439
; X64-POPCNT-NEXT: addl %eax, %eax
464
- ; X64-POPCNT-NEXT: andl $2, %eax
465
440
; X64-POPCNT-NEXT: # kill: def $ax killed $ax killed $eax
466
441
; X64-POPCNT-NEXT: retq
467
442
%2 = tail call i16 @llvm.ctpop.i16 (i16 %0 )
@@ -535,55 +510,37 @@ define i32 @parity_32_shift(i32 %0) {
535
510
; X86-NOPOPCNT: # %bb.0:
536
511
; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
537
512
; X86-NOPOPCNT-NEXT: movl %eax, %ecx
538
- ; X86-NOPOPCNT-NEXT: shrl %ecx
539
- ; X86-NOPOPCNT-NEXT: andl $1431655765, %ecx # imm = 0x55555555
540
- ; X86-NOPOPCNT-NEXT: subl %ecx, %eax
541
- ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
542
- ; X86-NOPOPCNT-NEXT: andl $858993459, %ecx # imm = 0x33333333
543
- ; X86-NOPOPCNT-NEXT: shrl $2, %eax
544
- ; X86-NOPOPCNT-NEXT: andl $858993459, %eax # imm = 0x33333333
545
- ; X86-NOPOPCNT-NEXT: addl %ecx, %eax
546
- ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
547
- ; X86-NOPOPCNT-NEXT: shrl $4, %ecx
548
- ; X86-NOPOPCNT-NEXT: addl %eax, %ecx
549
- ; X86-NOPOPCNT-NEXT: andl $17764111, %ecx # imm = 0x10F0F0F
550
- ; X86-NOPOPCNT-NEXT: imull $16843009, %ecx, %eax # imm = 0x1010101
551
- ; X86-NOPOPCNT-NEXT: shrl $23, %eax
552
- ; X86-NOPOPCNT-NEXT: andl $2, %eax
513
+ ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
514
+ ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
515
+ ; X86-NOPOPCNT-NEXT: xorl %eax, %eax
516
+ ; X86-NOPOPCNT-NEXT: xorb %ch, %cl
517
+ ; X86-NOPOPCNT-NEXT: setnp %al
518
+ ; X86-NOPOPCNT-NEXT: addl %eax, %eax
553
519
; X86-NOPOPCNT-NEXT: retl
554
520
;
555
521
; X64-NOPOPCNT-LABEL: parity_32_shift:
556
522
; X64-NOPOPCNT: # %bb.0:
557
- ; X64-NOPOPCNT-NEXT: movl %edi, %eax
558
- ; X64-NOPOPCNT-NEXT: shrl %eax
559
- ; X64-NOPOPCNT-NEXT: andl $1431655765, %eax # imm = 0x55555555
560
- ; X64-NOPOPCNT-NEXT: subl %eax, %edi
561
- ; X64-NOPOPCNT-NEXT: movl %edi, %eax
562
- ; X64-NOPOPCNT-NEXT: andl $858993459, %eax # imm = 0x33333333
563
- ; X64-NOPOPCNT-NEXT: shrl $2, %edi
564
- ; X64-NOPOPCNT-NEXT: andl $858993459, %edi # imm = 0x33333333
565
- ; X64-NOPOPCNT-NEXT: addl %eax, %edi
566
- ; X64-NOPOPCNT-NEXT: movl %edi, %eax
567
- ; X64-NOPOPCNT-NEXT: shrl $4, %eax
568
- ; X64-NOPOPCNT-NEXT: addl %edi, %eax
569
- ; X64-NOPOPCNT-NEXT: andl $17764111, %eax # imm = 0x10F0F0F
570
- ; X64-NOPOPCNT-NEXT: imull $16843009, %eax, %eax # imm = 0x1010101
571
- ; X64-NOPOPCNT-NEXT: shrl $23, %eax
572
- ; X64-NOPOPCNT-NEXT: andl $2, %eax
523
+ ; X64-NOPOPCNT-NEXT: movl %edi, %ecx
524
+ ; X64-NOPOPCNT-NEXT: shrl $16, %ecx
525
+ ; X64-NOPOPCNT-NEXT: xorl %edi, %ecx
526
+ ; X64-NOPOPCNT-NEXT: xorl %eax, %eax
527
+ ; X64-NOPOPCNT-NEXT: xorb %ch, %cl
528
+ ; X64-NOPOPCNT-NEXT: setnp %al
529
+ ; X64-NOPOPCNT-NEXT: addl %eax, %eax
573
530
; X64-NOPOPCNT-NEXT: retq
574
531
;
575
532
; X86-POPCNT-LABEL: parity_32_shift:
576
533
; X86-POPCNT: # %bb.0:
577
534
; X86-POPCNT-NEXT: popcntl {{[0-9]+}}(%esp), %eax
535
+ ; X86-POPCNT-NEXT: andl $1, %eax
578
536
; X86-POPCNT-NEXT: addl %eax, %eax
579
- ; X86-POPCNT-NEXT: andl $2, %eax
580
537
; X86-POPCNT-NEXT: retl
581
538
;
582
539
; X64-POPCNT-LABEL: parity_32_shift:
583
540
; X64-POPCNT: # %bb.0:
584
541
; X64-POPCNT-NEXT: popcntl %edi, %eax
542
+ ; X64-POPCNT-NEXT: andl $1, %eax
585
543
; X64-POPCNT-NEXT: addl %eax, %eax
586
- ; X64-POPCNT-NEXT: andl $2, %eax
587
544
; X64-POPCNT-NEXT: retq
588
545
%2 = tail call i32 @llvm.ctpop.i32 (i32 %0 )
589
546
%3 = shl nuw nsw i32 %2 , 1
@@ -658,22 +615,14 @@ define i64 @parity_64_shift(i64 %0) {
658
615
; X86-NOPOPCNT-LABEL: parity_64_shift:
659
616
; X86-NOPOPCNT: # %bb.0:
660
617
; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
661
- ; X86-NOPOPCNT-NEXT: movl {{[0-9]+}}(%esp), %ecx
662
- ; X86-NOPOPCNT-NEXT: movl %ecx, %edx
663
- ; X86-NOPOPCNT-NEXT: shrl $16, %edx
664
- ; X86-NOPOPCNT-NEXT: xorl %ecx, %edx
665
- ; X86-NOPOPCNT-NEXT: xorl %ecx, %ecx
666
- ; X86-NOPOPCNT-NEXT: xorb %dh, %dl
667
- ; X86-NOPOPCNT-NEXT: setnp %cl
668
- ; X86-NOPOPCNT-NEXT: movl %eax, %edx
669
- ; X86-NOPOPCNT-NEXT: shrl $16, %edx
670
- ; X86-NOPOPCNT-NEXT: xorl %eax, %edx
618
+ ; X86-NOPOPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
619
+ ; X86-NOPOPCNT-NEXT: movl %eax, %ecx
620
+ ; X86-NOPOPCNT-NEXT: shrl $16, %ecx
621
+ ; X86-NOPOPCNT-NEXT: xorl %eax, %ecx
671
622
; X86-NOPOPCNT-NEXT: xorl %eax, %eax
672
- ; X86-NOPOPCNT-NEXT: xorb %dh , %dl
623
+ ; X86-NOPOPCNT-NEXT: xorb %ch , %cl
673
624
; X86-NOPOPCNT-NEXT: setnp %al
674
- ; X86-NOPOPCNT-NEXT: addl %ecx, %eax
675
625
; X86-NOPOPCNT-NEXT: addl %eax, %eax
676
- ; X86-NOPOPCNT-NEXT: andl $2, %eax
677
626
; X86-NOPOPCNT-NEXT: xorl %edx, %edx
678
627
; X86-NOPOPCNT-NEXT: retl
679
628
;
@@ -688,24 +637,24 @@ define i64 @parity_64_shift(i64 %0) {
688
637
; X64-NOPOPCNT-NEXT: xorl %eax, %eax
689
638
; X64-NOPOPCNT-NEXT: xorb %ch, %cl
690
639
; X64-NOPOPCNT-NEXT: setnp %al
691
- ; X64-NOPOPCNT-NEXT: addl %eax , %eax
640
+ ; X64-NOPOPCNT-NEXT: addq %rax , %rax
692
641
; X64-NOPOPCNT-NEXT: retq
693
642
;
694
643
; X86-POPCNT-LABEL: parity_64_shift:
695
644
; X86-POPCNT: # %bb.0:
696
- ; X86-POPCNT-NEXT: popcntl {{[0-9]+}}(%esp), %ecx
697
- ; X86-POPCNT-NEXT: popcntl {{[0-9]+}}(%esp), %eax
698
- ; X86-POPCNT-NEXT: addl %ecx, %eax
645
+ ; X86-POPCNT-NEXT: movl {{[0-9]+}}(%esp), %eax
646
+ ; X86-POPCNT-NEXT: xorl {{[0-9]+}}(%esp), %eax
647
+ ; X86-POPCNT-NEXT: popcntl %eax, %eax
648
+ ; X86-POPCNT-NEXT: andl $1, %eax
699
649
; X86-POPCNT-NEXT: addl %eax, %eax
700
- ; X86-POPCNT-NEXT: andl $2, %eax
701
650
; X86-POPCNT-NEXT: xorl %edx, %edx
702
651
; X86-POPCNT-NEXT: retl
703
652
;
704
653
; X64-POPCNT-LABEL: parity_64_shift:
705
654
; X64-POPCNT: # %bb.0:
706
655
; X64-POPCNT-NEXT: popcntq %rdi, %rax
707
656
; X64-POPCNT-NEXT: andl $1, %eax
708
- ; X64-POPCNT-NEXT: addl %eax , %eax
657
+ ; X64-POPCNT-NEXT: addq %rax , %rax
709
658
; X64-POPCNT-NEXT: retq
710
659
%2 = tail call i64 @llvm.ctpop.i64 (i64 %0 )
711
660
%3 = shl nuw nsw i64 %2 , 1
0 commit comments