summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-06-22 22:17:05 +0000
committerSanjay Patel <spatel@rotateright.com>2017-06-22 22:17:05 +0000
commitff051957fc296283ad5e6423a5bc3e3b217cde2e (patch)
tree2bd2be180e2ea0d3c381b17867288e6d461ac545
parentd2edd137dfbfbd6e0db3ed17f806c99530cadcf1 (diff)
downloadbcm5719-llvm-ff051957fc296283ad5e6423a5bc3e3b217cde2e.tar.gz
bcm5719-llvm-ff051957fc296283ad5e6423a5bc3e3b217cde2e.zip
[x86] add more tests for select --> sbb transform; NFC
These are siblings of the tests added with r306032. llvm-svn: 306064
-rw-r--r--llvm/test/CodeGen/X86/sbb.ll65
1 files changed, 61 insertions, 4 deletions
diff --git a/llvm/test/CodeGen/X86/sbb.ll b/llvm/test/CodeGen/X86/sbb.ll
index 062c5d26247..61f639a7a95 100644
--- a/llvm/test/CodeGen/X86/sbb.ll
+++ b/llvm/test/CodeGen/X86/sbb.ll
@@ -30,7 +30,7 @@ define i16 @i16_select_0_or_neg1_as_math(i16 %x) {
ret i16 %add
}
-; (X !== 0) ? -1 : 0 --> 0 - (X != 0)
+; (X != 0) ? -1 : 0 --> 0 - (X != 0)
define i32 @i32_select_0_or_neg1_commuted(i32 %x) {
; CHECK-LABEL: i32_select_0_or_neg1_commuted:
@@ -43,7 +43,7 @@ define i32 @i32_select_0_or_neg1_commuted(i32 %x) {
ret i32 %sel
}
-; (X !== 0) ? -1 : 0 --> 0 - (X != 0)
+; (X != 0) ? -1 : 0 --> 0 - (X != 0)
define i64 @i64_select_0_or_neg1_commuted_as_math(i64 %x) {
; CHECK-LABEL: i64_select_0_or_neg1_commuted_as_math:
@@ -53,7 +53,64 @@ define i64 @i64_select_0_or_neg1_commuted_as_math(i64 %x) {
; CHECK-NEXT: retq
%cmp = icmp ne i64 %x, 0
%ext = zext i1 %cmp to i64
- %add = sub i64 0, %ext
- ret i64 %add
+ %sub = sub i64 0, %ext
+ ret i64 %sub
+}
+
+; (X == 0) ? -1 : 0 --> 0 - (X == 0)
+
+define i64 @i64_select_neg1_or_0(i64 %x) {
+; CHECK-LABEL: i64_select_neg1_or_0:
+; CHECK: # BB#0:
+; CHECK-NEXT: cmpq $1, %rdi
+; CHECK-NEXT: sbbq %rax, %rax
+; CHECK-NEXT: retq
+ %cmp = icmp eq i64 %x, 0
+ %sel = select i1 %cmp, i64 -1, i64 0
+ ret i64 %sel
+}
+
+; (X == 0) ? -1 : 0 --> 0 - (X == 0)
+
+define i32 @i32_select_neg1_or_0_as_math(i32 %x) {
+; CHECK-LABEL: i32_select_neg1_or_0_as_math:
+; CHECK: # BB#0:
+; CHECK-NEXT: xorl %eax, %eax
+; CHECK-NEXT: cmpl $1, %edi
+; CHECK-NEXT: sbbl $0, %eax
+; CHECK-NEXT: retq
+ %cmp = icmp eq i32 %x, 0
+ %ext = zext i1 %cmp to i32
+ %sub = sub i32 0, %ext
+ ret i32 %sub
+}
+
+; (X != 0) ? 0 : -1 --> (X != 0) - 1
+
+define i16 @i16_select_neg1_or_0_commuted(i16 %x) {
+; CHECK-LABEL: i16_select_neg1_or_0_commuted:
+; CHECK: # BB#0:
+; CHECK-NEXT: cmpw $1, %di
+; CHECK-NEXT: movw $-1, %ax
+; CHECK-NEXT: sbbw $-1, %ax
+; CHECK-NEXT: retq
+ %cmp = icmp ne i16 %x, 0
+ %sel = select i1 %cmp, i16 0, i16 -1
+ ret i16 %sel
+}
+
+; (X != 0) ? 0 : -1 --> (X != 0) - 1
+
+define i8 @i8_select_neg1_or_0_commuted_as_math(i8 %x) {
+; CHECK-LABEL: i8_select_neg1_or_0_commuted_as_math:
+; CHECK: # BB#0:
+; CHECK-NEXT: cmpb $1, %dil
+; CHECK-NEXT: movb $-1, %al
+; CHECK-NEXT: sbbb $-1, %al
+; CHECK-NEXT: retq
+ %cmp = icmp ne i8 %x, 0
+ %ext = zext i1 %cmp to i8
+ %add = add i8 %ext, -1
+ ret i8 %add
}
OpenPOWER on IntegriCloud