@@ -761,7 +761,6 @@ define i64 @andnot_bitreverse_i64(i64 %a0, i64 %a1) nounwind {
761761;
762762; X86-BMI-LABEL: andnot_bitreverse_i64:
763763; X86-BMI: # %bb.0:
764- ; X86-BMI-NEXT: pushl %esi
765764; X86-BMI-NEXT: movl {{[0-9]+}}(%esp), %ecx
766765; X86-BMI-NEXT: movl {{[0-9]+}}(%esp), %eax
767766; X86-BMI-NEXT: bswapl %eax
@@ -775,16 +774,13 @@ define i64 @andnot_bitreverse_i64(i64 %a0, i64 %a1) nounwind {
775774; X86-BMI-NEXT: andl $858993459, %edx # imm = 0x33333333
776775; X86-BMI-NEXT: shrl $2, %eax
777776; X86-BMI-NEXT: andl $858993459, %eax # imm = 0x33333333
778- ; X86-BMI-NEXT: leal (%eax,%edx,4), %esi
779- ; X86-BMI-NEXT: andl $1431655765, %esi # imm = 0x55555555
780- ; X86-BMI-NEXT: addl %esi, %esi
781- ; X86-BMI-NEXT: shll $2, %edx
782- ; X86-BMI-NEXT: notl %edx
783- ; X86-BMI-NEXT: andnl %edx, %eax, %eax
777+ ; X86-BMI-NEXT: leal (%eax,%edx,4), %eax
778+ ; X86-BMI-NEXT: movl %eax, %edx
779+ ; X86-BMI-NEXT: andl $1431655765, %edx # imm = 0x55555555
784780; X86-BMI-NEXT: shrl %eax
785- ; X86-BMI-NEXT: orl $-1431655766 , %eax # imm = 0xAAAAAAAA
786- ; X86-BMI-NEXT: andnl %eax, %esi , %eax
787- ; X86-BMI-NEXT: andl {{[0-9]+}}(%esp), %eax
781+ ; X86-BMI-NEXT: andl $1431655765 , %eax # imm = 0x55555555
782+ ; X86-BMI-NEXT: leal ( %eax,%edx,2) , %eax
783+ ; X86-BMI-NEXT: andnl {{[0-9]+}}(%esp), %eax , %eax
788784; X86-BMI-NEXT: bswapl %ecx
789785; X86-BMI-NEXT: movl %ecx, %edx
790786; X86-BMI-NEXT: andl $252645135, %edx # imm = 0xF0F0F0F
@@ -796,17 +792,13 @@ define i64 @andnot_bitreverse_i64(i64 %a0, i64 %a1) nounwind {
796792; X86-BMI-NEXT: andl $858993459, %edx # imm = 0x33333333
797793; X86-BMI-NEXT: shrl $2, %ecx
798794; X86-BMI-NEXT: andl $858993459, %ecx # imm = 0x33333333
799- ; X86-BMI-NEXT: leal (%ecx,%edx,4), %esi
800- ; X86-BMI-NEXT: andl $1431655765, %esi # imm = 0x55555555
801- ; X86-BMI-NEXT: addl %esi, %esi
802- ; X86-BMI-NEXT: shll $2, %edx
803- ; X86-BMI-NEXT: notl %edx
804- ; X86-BMI-NEXT: andnl %edx, %ecx, %ecx
795+ ; X86-BMI-NEXT: leal (%ecx,%edx,4), %ecx
796+ ; X86-BMI-NEXT: movl %ecx, %edx
797+ ; X86-BMI-NEXT: andl $1431655765, %edx # imm = 0x55555555
805798; X86-BMI-NEXT: shrl %ecx
806- ; X86-BMI-NEXT: orl $-1431655766, %ecx # imm = 0xAAAAAAAA
807- ; X86-BMI-NEXT: andnl %ecx, %esi, %edx
808- ; X86-BMI-NEXT: andl {{[0-9]+}}(%esp), %edx
809- ; X86-BMI-NEXT: popl %esi
799+ ; X86-BMI-NEXT: andl $1431655765, %ecx # imm = 0x55555555
800+ ; X86-BMI-NEXT: leal (%ecx,%edx,2), %ecx
801+ ; X86-BMI-NEXT: andnl {{[0-9]+}}(%esp), %ecx, %edx
810802; X86-BMI-NEXT: retl
811803;
812804; X64-NOBMI-LABEL: andnot_bitreverse_i64:
@@ -845,23 +837,19 @@ define i64 @andnot_bitreverse_i64(i64 %a0, i64 %a1) nounwind {
845837; X64-BMI-NEXT: andq %rcx, %rsi
846838; X64-BMI-NEXT: shlq $4, %rsi
847839; X64-BMI-NEXT: orq %rax, %rsi
848- ; X64-BMI-NEXT: movq %rsi, %rax
849- ; X64-BMI-NEXT: shrq $2, %rax
850- ; X64-BMI-NEXT: movabsq $3689348814741910323, %rcx # imm = 0x3333333333333333
851- ; X64-BMI-NEXT: andq %rcx, %rax
852- ; X64-BMI-NEXT: andq %rcx, %rsi
853- ; X64-BMI-NEXT: leaq (,%rsi,4), %rcx
854- ; X64-BMI-NEXT: notq %rcx
855- ; X64-BMI-NEXT: andnq %rcx, %rax, %rcx
856- ; X64-BMI-NEXT: shrq %rcx
857- ; X64-BMI-NEXT: movabsq $-6148914691236517206, %rdx # imm = 0xAAAAAAAAAAAAAAAA
858- ; X64-BMI-NEXT: orq %rcx, %rdx
859- ; X64-BMI-NEXT: leaq (%rax,%rsi,4), %rax
860- ; X64-BMI-NEXT: movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
840+ ; X64-BMI-NEXT: movabsq $3689348814741910323, %rax # imm = 0x3333333333333333
841+ ; X64-BMI-NEXT: movq %rsi, %rcx
861842; X64-BMI-NEXT: andq %rax, %rcx
862- ; X64-BMI-NEXT: addq %rcx, %rcx
863- ; X64-BMI-NEXT: andnq %rdx, %rcx, %rax
864- ; X64-BMI-NEXT: andq %rdi, %rax
843+ ; X64-BMI-NEXT: shrq $2, %rsi
844+ ; X64-BMI-NEXT: andq %rax, %rsi
845+ ; X64-BMI-NEXT: leaq (%rsi,%rcx,4), %rax
846+ ; X64-BMI-NEXT: movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
847+ ; X64-BMI-NEXT: movq %rax, %rdx
848+ ; X64-BMI-NEXT: andq %rcx, %rdx
849+ ; X64-BMI-NEXT: shrq %rax
850+ ; X64-BMI-NEXT: andq %rcx, %rax
851+ ; X64-BMI-NEXT: leaq (%rax,%rdx,2), %rax
852+ ; X64-BMI-NEXT: andnq %rdi, %rax, %rax
865853; X64-BMI-NEXT: retq
866854 %not = xor i64 %a1 , -1
867855 %bitrev = tail call i64 @llvm.bitreverse.i64 (i64 %not )
@@ -908,16 +896,13 @@ define i32 @andnot_bitreverse_i32(i32 %a0, i32 %a1) nounwind {
908896; X86-BMI-NEXT: andl $858993459, %ecx # imm = 0x33333333
909897; X86-BMI-NEXT: shrl $2, %eax
910898; X86-BMI-NEXT: andl $858993459, %eax # imm = 0x33333333
911- ; X86-BMI-NEXT: leal (%eax,%ecx,4), %edx
912- ; X86-BMI-NEXT: andl $1431655765, %edx # imm = 0x55555555
913- ; X86-BMI-NEXT: addl %edx, %edx
914- ; X86-BMI-NEXT: shll $2, %ecx
915- ; X86-BMI-NEXT: notl %ecx
916- ; X86-BMI-NEXT: andnl %ecx, %eax, %eax
899+ ; X86-BMI-NEXT: leal (%eax,%ecx,4), %eax
900+ ; X86-BMI-NEXT: movl %eax, %ecx
901+ ; X86-BMI-NEXT: andl $1431655765, %ecx # imm = 0x55555555
917902; X86-BMI-NEXT: shrl %eax
918- ; X86-BMI-NEXT: orl $-1431655766 , %eax # imm = 0xAAAAAAAA
919- ; X86-BMI-NEXT: andnl %eax, %edx , %eax
920- ; X86-BMI-NEXT: andl {{[0-9]+}}(%esp), %eax
903+ ; X86-BMI-NEXT: andl $1431655765 , %eax # imm = 0x55555555
904+ ; X86-BMI-NEXT: leal ( %eax,%ecx,2) , %eax
905+ ; X86-BMI-NEXT: andnl {{[0-9]+}}(%esp), %eax , %eax
921906; X86-BMI-NEXT: retl
922907;
923908; X64-NOBMI-LABEL: andnot_bitreverse_i32:
@@ -955,19 +940,16 @@ define i32 @andnot_bitreverse_i32(i32 %a0, i32 %a1) nounwind {
955940; X64-BMI-NEXT: andl $252645135, %esi # imm = 0xF0F0F0F
956941; X64-BMI-NEXT: orl %eax, %esi
957942; X64-BMI-NEXT: movl %esi, %eax
958- ; X64-BMI-NEXT: shrl $2, %eax
959943; X64-BMI-NEXT: andl $858993459, %eax # imm = 0x33333333
944+ ; X64-BMI-NEXT: shrl $2, %esi
960945; X64-BMI-NEXT: andl $858993459, %esi # imm = 0x33333333
961- ; X64-BMI-NEXT: leal (,%rsi,4), %ecx
962- ; X64-BMI-NEXT: notl %ecx
963- ; X64-BMI-NEXT: andnl %ecx, %eax, %ecx
964- ; X64-BMI-NEXT: shrl %ecx
965- ; X64-BMI-NEXT: orl $-1431655766, %ecx # imm = 0xAAAAAAAA
966- ; X64-BMI-NEXT: leal (%rax,%rsi,4), %eax
946+ ; X64-BMI-NEXT: leal (%rsi,%rax,4), %eax
947+ ; X64-BMI-NEXT: movl %eax, %ecx
948+ ; X64-BMI-NEXT: andl $1431655765, %ecx # imm = 0x55555555
949+ ; X64-BMI-NEXT: shrl %eax
967950; X64-BMI-NEXT: andl $1431655765, %eax # imm = 0x55555555
968- ; X64-BMI-NEXT: addl %eax, %eax
969- ; X64-BMI-NEXT: andnl %ecx, %eax, %eax
970- ; X64-BMI-NEXT: andl %edi, %eax
951+ ; X64-BMI-NEXT: leal (%rax,%rcx,2), %eax
952+ ; X64-BMI-NEXT: andnl %edi, %eax, %eax
971953; X64-BMI-NEXT: retq
972954 %not = xor i32 %a1 , -1
973955 %bitrev = tail call i32 @llvm.bitreverse.i32 (i32 %not )
@@ -976,57 +958,30 @@ define i32 @andnot_bitreverse_i32(i32 %a0, i32 %a1) nounwind {
976958}
977959
978960define i16 @andnot_bitreverse_i16 (i16 %a0 , i16 %a1 ) nounwind {
979- ; X86-NOBMI-LABEL: andnot_bitreverse_i16:
980- ; X86-NOBMI: # %bb.0:
981- ; X86-NOBMI-NEXT: movzwl {{[0-9]+}}(%esp), %eax
982- ; X86-NOBMI-NEXT: rolw $8, %ax
983- ; X86-NOBMI-NEXT: movl %eax, %ecx
984- ; X86-NOBMI-NEXT: andl $3855, %ecx # imm = 0xF0F
985- ; X86-NOBMI-NEXT: shll $4, %ecx
986- ; X86-NOBMI-NEXT: shrl $4, %eax
987- ; X86-NOBMI-NEXT: andl $3855, %eax # imm = 0xF0F
988- ; X86-NOBMI-NEXT: orl %ecx, %eax
989- ; X86-NOBMI-NEXT: movl %eax, %ecx
990- ; X86-NOBMI-NEXT: andl $13107, %ecx # imm = 0x3333
991- ; X86-NOBMI-NEXT: shrl $2, %eax
992- ; X86-NOBMI-NEXT: andl $13107, %eax # imm = 0x3333
993- ; X86-NOBMI-NEXT: leal (%eax,%ecx,4), %eax
994- ; X86-NOBMI-NEXT: movl %eax, %ecx
995- ; X86-NOBMI-NEXT: andl $21845, %ecx # imm = 0x5555
996- ; X86-NOBMI-NEXT: shrl %eax
997- ; X86-NOBMI-NEXT: andl $21845, %eax # imm = 0x5555
998- ; X86-NOBMI-NEXT: leal (%eax,%ecx,2), %eax
999- ; X86-NOBMI-NEXT: notl %eax
1000- ; X86-NOBMI-NEXT: andw {{[0-9]+}}(%esp), %ax
1001- ; X86-NOBMI-NEXT: # kill: def $ax killed $ax killed $eax
1002- ; X86-NOBMI-NEXT: retl
1003- ;
1004- ; X86-BMI-LABEL: andnot_bitreverse_i16:
1005- ; X86-BMI: # %bb.0:
1006- ; X86-BMI-NEXT: movzwl {{[0-9]+}}(%esp), %eax
1007- ; X86-BMI-NEXT: rolw $8, %ax
1008- ; X86-BMI-NEXT: movl %eax, %ecx
1009- ; X86-BMI-NEXT: andl $3855, %ecx # imm = 0xF0F
1010- ; X86-BMI-NEXT: shll $4, %ecx
1011- ; X86-BMI-NEXT: shrl $4, %eax
1012- ; X86-BMI-NEXT: andl $3855, %eax # imm = 0xF0F
1013- ; X86-BMI-NEXT: orl %ecx, %eax
1014- ; X86-BMI-NEXT: movl %eax, %ecx
1015- ; X86-BMI-NEXT: andl $13107, %ecx # imm = 0x3333
1016- ; X86-BMI-NEXT: shrl $2, %eax
1017- ; X86-BMI-NEXT: andl $13107, %eax # imm = 0x3333
1018- ; X86-BMI-NEXT: leal (%eax,%ecx,4), %edx
1019- ; X86-BMI-NEXT: andl $21845, %edx # imm = 0x5555
1020- ; X86-BMI-NEXT: addl %edx, %edx
1021- ; X86-BMI-NEXT: shll $2, %ecx
1022- ; X86-BMI-NEXT: notl %ecx
1023- ; X86-BMI-NEXT: andnl %ecx, %eax, %eax
1024- ; X86-BMI-NEXT: shrl %eax
1025- ; X86-BMI-NEXT: orl $43690, %eax # imm = 0xAAAA
1026- ; X86-BMI-NEXT: andnl %eax, %edx, %eax
1027- ; X86-BMI-NEXT: andw {{[0-9]+}}(%esp), %ax
1028- ; X86-BMI-NEXT: # kill: def $ax killed $ax killed $eax
1029- ; X86-BMI-NEXT: retl
961+ ; X86-LABEL: andnot_bitreverse_i16:
962+ ; X86: # %bb.0:
963+ ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
964+ ; X86-NEXT: rolw $8, %ax
965+ ; X86-NEXT: movl %eax, %ecx
966+ ; X86-NEXT: andl $3855, %ecx # imm = 0xF0F
967+ ; X86-NEXT: shll $4, %ecx
968+ ; X86-NEXT: shrl $4, %eax
969+ ; X86-NEXT: andl $3855, %eax # imm = 0xF0F
970+ ; X86-NEXT: orl %ecx, %eax
971+ ; X86-NEXT: movl %eax, %ecx
972+ ; X86-NEXT: andl $13107, %ecx # imm = 0x3333
973+ ; X86-NEXT: shrl $2, %eax
974+ ; X86-NEXT: andl $13107, %eax # imm = 0x3333
975+ ; X86-NEXT: leal (%eax,%ecx,4), %eax
976+ ; X86-NEXT: movl %eax, %ecx
977+ ; X86-NEXT: andl $21845, %ecx # imm = 0x5555
978+ ; X86-NEXT: shrl %eax
979+ ; X86-NEXT: andl $21845, %eax # imm = 0x5555
980+ ; X86-NEXT: leal (%eax,%ecx,2), %eax
981+ ; X86-NEXT: notl %eax
982+ ; X86-NEXT: andw {{[0-9]+}}(%esp), %ax
983+ ; X86-NEXT: # kill: def $ax killed $ax killed $eax
984+ ; X86-NEXT: retl
1030985;
1031986; X64-NOBMI-LABEL: andnot_bitreverse_i16:
1032987; X64-NOBMI: # %bb.0:
@@ -1064,19 +1019,16 @@ define i16 @andnot_bitreverse_i16(i16 %a0, i16 %a1) nounwind {
10641019; X64-BMI-NEXT: andl $3855, %esi # imm = 0xF0F
10651020; X64-BMI-NEXT: orl %eax, %esi
10661021; X64-BMI-NEXT: movl %esi, %eax
1067- ; X64-BMI-NEXT: shrl $2, %eax
10681022; X64-BMI-NEXT: andl $13107, %eax # imm = 0x3333
1023+ ; X64-BMI-NEXT: shrl $2, %esi
10691024; X64-BMI-NEXT: andl $13107, %esi # imm = 0x3333
1070- ; X64-BMI-NEXT: leal (,%rsi,4), %ecx
1071- ; X64-BMI-NEXT: notl %ecx
1072- ; X64-BMI-NEXT: andnl %ecx, %eax, %ecx
1073- ; X64-BMI-NEXT: shrl %ecx
1074- ; X64-BMI-NEXT: orl $-21846, %ecx # imm = 0xAAAA
1075- ; X64-BMI-NEXT: leal (%rax,%rsi,4), %eax
1025+ ; X64-BMI-NEXT: leal (%rsi,%rax,4), %eax
1026+ ; X64-BMI-NEXT: movl %eax, %ecx
1027+ ; X64-BMI-NEXT: andl $21845, %ecx # imm = 0x5555
1028+ ; X64-BMI-NEXT: shrl %eax
10761029; X64-BMI-NEXT: andl $21845, %eax # imm = 0x5555
1077- ; X64-BMI-NEXT: addl %eax, %eax
1078- ; X64-BMI-NEXT: andnl %ecx, %eax, %eax
1079- ; X64-BMI-NEXT: andl %edi, %eax
1030+ ; X64-BMI-NEXT: leal (%rax,%rcx,2), %eax
1031+ ; X64-BMI-NEXT: andnl %edi, %eax, %eax
10801032; X64-BMI-NEXT: # kill: def $ax killed $ax killed $eax
10811033; X64-BMI-NEXT: retq
10821034 %not = xor i16 %a1 , -1
0 commit comments