Skip to content

Commit 40c7243

Browse files
committed
[x86] add tests for select with -1 operand; NFC
1 parent e3b442b commit 40c7243

File tree

1 file changed

+188
-24
lines changed

1 file changed

+188
-24
lines changed

llvm/test/CodeGen/X86/select.ll

Lines changed: 188 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,170 @@ define i64 @test11a(i64 %x, i64 %y) nounwind readnone ssp noredzone {
868868
ret i64 %cond
869869
}
870870

871+
define i32 @eqzero_const_or_all_ones(i32 %x) {
872+
; CHECK-LABEL: eqzero_const_or_all_ones:
873+
; CHECK: ## %bb.0:
874+
; CHECK-NEXT: xorl %eax, %eax
875+
; CHECK-NEXT: cmpl $1, %edi
876+
; CHECK-NEXT: sbbl %eax, %eax
877+
; CHECK-NEXT: notl %eax
878+
; CHECK-NEXT: orl $42, %eax
879+
; CHECK-NEXT: retq
880+
;
881+
; ATHLON-LABEL: eqzero_const_or_all_ones:
882+
; ATHLON: ## %bb.0:
883+
; ATHLON-NEXT: xorl %eax, %eax
884+
; ATHLON-NEXT: cmpl $1, {{[0-9]+}}(%esp)
885+
; ATHLON-NEXT: sbbl %eax, %eax
886+
; ATHLON-NEXT: notl %eax
887+
; ATHLON-NEXT: orl $42, %eax
888+
; ATHLON-NEXT: retl
889+
;
890+
; MCU-LABEL: eqzero_const_or_all_ones:
891+
; MCU: # %bb.0:
892+
; MCU-NEXT: xorl %ecx, %ecx
893+
; MCU-NEXT: cmpl $1, %eax
894+
; MCU-NEXT: sbbl %ecx, %ecx
895+
; MCU-NEXT: notl %ecx
896+
; MCU-NEXT: orl $42, %ecx
897+
; MCU-NEXT: movl %ecx, %eax
898+
; MCU-NEXT: retl
899+
%z = icmp eq i32 %x, 0
900+
%r = select i1 %z, i32 42, i32 -1
901+
ret i32 %r
902+
}
903+
904+
define i32 @nezero_const_or_all_ones(i32 %x) {
905+
; CHECK-LABEL: nezero_const_or_all_ones:
906+
; CHECK: ## %bb.0:
907+
; CHECK-NEXT: xorl %eax, %eax
908+
; CHECK-NEXT: cmpl $1, %edi
909+
; CHECK-NEXT: sbbl %eax, %eax
910+
; CHECK-NEXT: orl $42, %eax
911+
; CHECK-NEXT: retq
912+
;
913+
; ATHLON-LABEL: nezero_const_or_all_ones:
914+
; ATHLON: ## %bb.0:
915+
; ATHLON-NEXT: xorl %eax, %eax
916+
; ATHLON-NEXT: cmpl $1, {{[0-9]+}}(%esp)
917+
; ATHLON-NEXT: sbbl %eax, %eax
918+
; ATHLON-NEXT: orl $42, %eax
919+
; ATHLON-NEXT: retl
920+
;
921+
; MCU-LABEL: nezero_const_or_all_ones:
922+
; MCU: # %bb.0:
923+
; MCU-NEXT: xorl %ecx, %ecx
924+
; MCU-NEXT: cmpl $1, %eax
925+
; MCU-NEXT: sbbl %ecx, %ecx
926+
; MCU-NEXT: orl $42, %ecx
927+
; MCU-NEXT: movl %ecx, %eax
928+
; MCU-NEXT: retl
929+
%z = icmp ne i32 %x, 0
930+
%r = select i1 %z, i32 42, i32 -1
931+
ret i32 %r
932+
}
933+
934+
define i64 @eqzero_all_ones_or_const(i64 %x) {
935+
; CHECK-LABEL: eqzero_all_ones_or_const:
936+
; CHECK: ## %bb.0:
937+
; CHECK-NEXT: xorl %eax, %eax
938+
; CHECK-NEXT: cmpq $1, %rdi
939+
; CHECK-NEXT: sbbq %rax, %rax
940+
; CHECK-NEXT: orq $42, %rax
941+
; CHECK-NEXT: retq
942+
;
943+
; ATHLON-LABEL: eqzero_all_ones_or_const:
944+
; ATHLON: ## %bb.0:
945+
; ATHLON-NEXT: movl {{[0-9]+}}(%esp), %eax
946+
; ATHLON-NEXT: xorl %edx, %edx
947+
; ATHLON-NEXT: orl {{[0-9]+}}(%esp), %eax
948+
; ATHLON-NEXT: movl $-1, %ecx
949+
; ATHLON-NEXT: movl $42, %eax
950+
; ATHLON-NEXT: cmovel %ecx, %eax
951+
; ATHLON-NEXT: cmovel %ecx, %edx
952+
; ATHLON-NEXT: retl
953+
;
954+
; MCU-LABEL: eqzero_all_ones_or_const:
955+
; MCU: # %bb.0:
956+
; MCU-NEXT: orl %edx, %eax
957+
; MCU-NEXT: movl $-1, %eax
958+
; MCU-NEXT: movl $-1, %edx
959+
; MCU-NEXT: je .LBB16_2
960+
; MCU-NEXT: # %bb.1:
961+
; MCU-NEXT: xorl %edx, %edx
962+
; MCU-NEXT: movl $42, %eax
963+
; MCU-NEXT: .LBB16_2:
964+
; MCU-NEXT: retl
965+
%z = icmp eq i64 %x, 0
966+
%r = select i1 %z, i64 -1, i64 42
967+
ret i64 %r
968+
}
969+
970+
define i8 @nezero_all_ones_or_const(i8 %x) {
971+
; CHECK-LABEL: nezero_all_ones_or_const:
972+
; CHECK: ## %bb.0:
973+
; CHECK-NEXT: xorl %eax, %eax
974+
; CHECK-NEXT: cmpb $1, %dil
975+
; CHECK-NEXT: sbbl %eax, %eax
976+
; CHECK-NEXT: notb %al
977+
; CHECK-NEXT: orb $42, %al
978+
; CHECK-NEXT: ## kill: def $al killed $al killed $eax
979+
; CHECK-NEXT: retq
980+
;
981+
; ATHLON-LABEL: nezero_all_ones_or_const:
982+
; ATHLON: ## %bb.0:
983+
; ATHLON-NEXT: xorl %eax, %eax
984+
; ATHLON-NEXT: cmpb $1, {{[0-9]+}}(%esp)
985+
; ATHLON-NEXT: sbbl %eax, %eax
986+
; ATHLON-NEXT: notb %al
987+
; ATHLON-NEXT: orb $42, %al
988+
; ATHLON-NEXT: ## kill: def $al killed $al killed $eax
989+
; ATHLON-NEXT: retl
990+
;
991+
; MCU-LABEL: nezero_all_ones_or_const:
992+
; MCU: # %bb.0:
993+
; MCU-NEXT: movl %eax, %ecx
994+
; MCU-NEXT: xorl %eax, %eax
995+
; MCU-NEXT: cmpb $1, %cl
996+
; MCU-NEXT: sbbl %eax, %eax
997+
; MCU-NEXT: notb %al
998+
; MCU-NEXT: orb $42, %al
999+
; MCU-NEXT: # kill: def $al killed $al killed $eax
1000+
; MCU-NEXT: retl
1001+
%z = icmp ne i8 %x, 0
1002+
%r = select i1 %z, i8 -1, i8 42
1003+
ret i8 %r
1004+
}
1005+
1006+
define i32 @PR53006(i32 %x) {
1007+
; CHECK-LABEL: PR53006:
1008+
; CHECK: ## %bb.0:
1009+
; CHECK-NEXT: xorl %eax, %eax
1010+
; CHECK-NEXT: testl %edi, %edi
1011+
; CHECK-NEXT: sete %al
1012+
; CHECK-NEXT: leal -1(%rax,%rax), %eax
1013+
; CHECK-NEXT: retq
1014+
;
1015+
; ATHLON-LABEL: PR53006:
1016+
; ATHLON: ## %bb.0:
1017+
; ATHLON-NEXT: xorl %eax, %eax
1018+
; ATHLON-NEXT: cmpl $0, {{[0-9]+}}(%esp)
1019+
; ATHLON-NEXT: sete %al
1020+
; ATHLON-NEXT: leal -1(%eax,%eax), %eax
1021+
; ATHLON-NEXT: retl
1022+
;
1023+
; MCU-LABEL: PR53006:
1024+
; MCU: # %bb.0:
1025+
; MCU-NEXT: xorl %ecx, %ecx
1026+
; MCU-NEXT: testl %eax, %eax
1027+
; MCU-NEXT: sete %cl
1028+
; MCU-NEXT: leal -1(%ecx,%ecx), %eax
1029+
; MCU-NEXT: retl
1030+
%z = icmp eq i32 %x, 0
1031+
%r = select i1 %z, i32 1, i32 -1
1032+
ret i32 %r
1033+
}
1034+
8711035
define i32 @test13(i32 %a, i32 %b) nounwind {
8721036
; GENERIC-LABEL: test13:
8731037
; GENERIC: ## %bb.0:
@@ -1087,10 +1251,10 @@ define i8 @test18(i32 %x, i8 zeroext %a, i8 zeroext %b) nounwind {
10871251
; MCU-LABEL: test18:
10881252
; MCU: # %bb.0:
10891253
; MCU-NEXT: cmpl $15, %eax
1090-
; MCU-NEXT: jl .LBB19_2
1254+
; MCU-NEXT: jl .LBB24_2
10911255
; MCU-NEXT: # %bb.1:
10921256
; MCU-NEXT: movl %ecx, %edx
1093-
; MCU-NEXT: .LBB19_2:
1257+
; MCU-NEXT: .LBB24_2:
10941258
; MCU-NEXT: movl %edx, %eax
10951259
; MCU-NEXT: retl
10961260
%cmp = icmp slt i32 %x, 15
@@ -1180,16 +1344,16 @@ define void @clamp_i8(i32 %src, i8* %dst) {
11801344
; MCU: # %bb.0:
11811345
; MCU-NEXT: cmpl $127, %eax
11821346
; MCU-NEXT: movl $127, %ecx
1183-
; MCU-NEXT: jg .LBB21_2
1347+
; MCU-NEXT: jg .LBB26_2
11841348
; MCU-NEXT: # %bb.1:
11851349
; MCU-NEXT: movl %eax, %ecx
1186-
; MCU-NEXT: .LBB21_2:
1350+
; MCU-NEXT: .LBB26_2:
11871351
; MCU-NEXT: cmpl $-128, %ecx
11881352
; MCU-NEXT: movb $-128, %al
1189-
; MCU-NEXT: jl .LBB21_4
1353+
; MCU-NEXT: jl .LBB26_4
11901354
; MCU-NEXT: # %bb.3:
11911355
; MCU-NEXT: movl %ecx, %eax
1192-
; MCU-NEXT: .LBB21_4:
1356+
; MCU-NEXT: .LBB26_4:
11931357
; MCU-NEXT: movb %al, (%edx)
11941358
; MCU-NEXT: retl
11951359
%cmp = icmp sgt i32 %src, 127
@@ -1242,16 +1406,16 @@ define void @clamp(i32 %src, i16* %dst) {
12421406
; MCU: # %bb.0:
12431407
; MCU-NEXT: cmpl $32768, %eax # imm = 0x8000
12441408
; MCU-NEXT: movl $32767, %ecx # imm = 0x7FFF
1245-
; MCU-NEXT: jge .LBB22_2
1409+
; MCU-NEXT: jge .LBB27_2
12461410
; MCU-NEXT: # %bb.1:
12471411
; MCU-NEXT: movl %eax, %ecx
1248-
; MCU-NEXT: .LBB22_2:
1412+
; MCU-NEXT: .LBB27_2:
12491413
; MCU-NEXT: cmpl $-32768, %ecx # imm = 0x8000
12501414
; MCU-NEXT: movl $32768, %eax # imm = 0x8000
1251-
; MCU-NEXT: jl .LBB22_4
1415+
; MCU-NEXT: jl .LBB27_4
12521416
; MCU-NEXT: # %bb.3:
12531417
; MCU-NEXT: movl %ecx, %eax
1254-
; MCU-NEXT: .LBB22_4:
1418+
; MCU-NEXT: .LBB27_4:
12551419
; MCU-NEXT: movw %ax, (%edx)
12561420
; MCU-NEXT: retl
12571421
%cmp = icmp sgt i32 %src, 32767
@@ -1324,10 +1488,10 @@ define i16 @select_xor_1b(i16 %A, i8 %cond) {
13241488
; MCU-LABEL: select_xor_1b:
13251489
; MCU: # %bb.0: # %entry
13261490
; MCU-NEXT: testb $1, %dl
1327-
; MCU-NEXT: je .LBB24_2
1491+
; MCU-NEXT: je .LBB29_2
13281492
; MCU-NEXT: # %bb.1:
13291493
; MCU-NEXT: xorl $43, %eax
1330-
; MCU-NEXT: .LBB24_2: # %entry
1494+
; MCU-NEXT: .LBB29_2: # %entry
13311495
; MCU-NEXT: # kill: def $ax killed $ax killed $eax
13321496
; MCU-NEXT: retl
13331497
entry:
@@ -1394,10 +1558,10 @@ define i32 @select_xor_2b(i32 %A, i32 %B, i8 %cond) {
13941558
; MCU-LABEL: select_xor_2b:
13951559
; MCU: # %bb.0: # %entry
13961560
; MCU-NEXT: testb $1, %cl
1397-
; MCU-NEXT: je .LBB26_2
1561+
; MCU-NEXT: je .LBB31_2
13981562
; MCU-NEXT: # %bb.1:
13991563
; MCU-NEXT: xorl %edx, %eax
1400-
; MCU-NEXT: .LBB26_2: # %entry
1564+
; MCU-NEXT: .LBB31_2: # %entry
14011565
; MCU-NEXT: retl
14021566
entry:
14031567
%and = and i8 %cond, 1
@@ -1463,10 +1627,10 @@ define i32 @select_or_b(i32 %A, i32 %B, i8 %cond) {
14631627
; MCU-LABEL: select_or_b:
14641628
; MCU: # %bb.0: # %entry
14651629
; MCU-NEXT: testb $1, %cl
1466-
; MCU-NEXT: je .LBB28_2
1630+
; MCU-NEXT: je .LBB33_2
14671631
; MCU-NEXT: # %bb.1:
14681632
; MCU-NEXT: orl %edx, %eax
1469-
; MCU-NEXT: .LBB28_2: # %entry
1633+
; MCU-NEXT: .LBB33_2: # %entry
14701634
; MCU-NEXT: retl
14711635
entry:
14721636
%and = and i8 %cond, 1
@@ -1532,10 +1696,10 @@ define i32 @select_or_1b(i32 %A, i32 %B, i32 %cond) {
15321696
; MCU-LABEL: select_or_1b:
15331697
; MCU: # %bb.0: # %entry
15341698
; MCU-NEXT: testb $1, %cl
1535-
; MCU-NEXT: je .LBB30_2
1699+
; MCU-NEXT: je .LBB35_2
15361700
; MCU-NEXT: # %bb.1:
15371701
; MCU-NEXT: orl %edx, %eax
1538-
; MCU-NEXT: .LBB30_2: # %entry
1702+
; MCU-NEXT: .LBB35_2: # %entry
15391703
; MCU-NEXT: retl
15401704
entry:
15411705
%and = and i32 %cond, 1
@@ -1571,11 +1735,11 @@ define i64 @PR51612(i64 %x, i64 %y) {
15711735
; MCU: # %bb.0:
15721736
; MCU-NEXT: addl $1, %eax
15731737
; MCU-NEXT: adcl $0, %edx
1574-
; MCU-NEXT: jae .LBB31_2
1738+
; MCU-NEXT: jae .LBB36_2
15751739
; MCU-NEXT: # %bb.1:
15761740
; MCU-NEXT: movl {{[0-9]+}}(%esp), %eax
15771741
; MCU-NEXT: incl %eax
1578-
; MCU-NEXT: .LBB31_2:
1742+
; MCU-NEXT: .LBB36_2:
15791743
; MCU-NEXT: andl 10, %eax
15801744
; MCU-NEXT: xorl %edx, %edx
15811745
; MCU-NEXT: retl
@@ -1630,10 +1794,10 @@ define i8 @select_uaddo_common_op0(i8 %a, i8 %b, i8 %c, i1 %cond) {
16301794
; MCU-LABEL: select_uaddo_common_op0:
16311795
; MCU: # %bb.0:
16321796
; MCU-NEXT: testb $1, {{[0-9]+}}(%esp)
1633-
; MCU-NEXT: jne .LBB32_2
1797+
; MCU-NEXT: jne .LBB37_2
16341798
; MCU-NEXT: # %bb.1:
16351799
; MCU-NEXT: movl %ecx, %edx
1636-
; MCU-NEXT: .LBB32_2:
1800+
; MCU-NEXT: .LBB37_2:
16371801
; MCU-NEXT: addb %dl, %al
16381802
; MCU-NEXT: # kill: def $al killed $al killed $eax
16391803
; MCU-NEXT: retl
@@ -1679,10 +1843,10 @@ define i32 @select_uaddo_common_op1(i32 %a, i32 %b, i32 %c, i1 %cond) {
16791843
; MCU-LABEL: select_uaddo_common_op1:
16801844
; MCU: # %bb.0:
16811845
; MCU-NEXT: testb $1, {{[0-9]+}}(%esp)
1682-
; MCU-NEXT: jne .LBB33_2
1846+
; MCU-NEXT: jne .LBB38_2
16831847
; MCU-NEXT: # %bb.1:
16841848
; MCU-NEXT: movl %ecx, %eax
1685-
; MCU-NEXT: .LBB33_2:
1849+
; MCU-NEXT: .LBB38_2:
16861850
; MCU-NEXT: addl %edx, %eax
16871851
; MCU-NEXT: retl
16881852
%ab = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)

0 commit comments

Comments
 (0)