generalize the previous check to handle -1 on either side of the
select, inserting a not to compensate. Add a missing isZero check
that I lost somehow.
This improves codegen of:
void *func(long count) {
return new int[count];
}
from:
__Z4funcl: ## @_Z4funcl
movl $4, %ecx ## encoding: [0xb9,0x04,0x00,0x00,0x00]
movq %rdi, %rax ## encoding: [0x48,0x89,0xf8]
mulq %rcx ## encoding: [0x48,0xf7,0xe1]
testq %rdx, %rdx ## encoding: [0x48,0x85,0xd2]
movq $-1, %rdi ## encoding: [0x48,0xc7,0xc7,0xff,0xff,0xff,0xff]
cmoveq %rax, %rdi ## encoding: [0x48,0x0f,0x44,0xf8]
jmp __Znam ## TAILCALL
## encoding: [0xeb,A]
to:
__Z4funcl: ## @_Z4funcl
movl $4, %ecx ## encoding: [0xb9,0x04,0x00,0x00,0x00]
movq %rdi, %rax ## encoding: [0x48,0x89,0xf8]
mulq %rcx ## encoding: [0x48,0xf7,0xe1]
cmpq $1, %rdx ## encoding: [0x48,0x83,0xfa,0x01]
sbbq %rdi, %rdi ## encoding: [0x48,0x19,0xff]
notq %rdi ## encoding: [0x48,0xf7,0xd7]
orq %rax, %rdi ## encoding: [0x48,0x09,0xc7]
jmp __Znam ## TAILCALL
## encoding: [0xeb,A]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120932 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/X86/select.ll b/test/CodeGen/X86/select.ll
index 8b8fb3b..11ace19a 100644
--- a/test/CodeGen/X86/select.ll
+++ b/test/CodeGen/X86/select.ll
@@ -153,5 +153,29 @@
+define i64 @test11(i64 %x, i64 %y) nounwind readnone ssp noredzone {
+ %cmp = icmp eq i64 %x, 0
+ %cond = select i1 %cmp, i64 %y, i64 -1
+ ret i64 %cond
+; CHECK: test11:
+; CHECK: cmpq $1, %rdi
+; CHECK: sbbq %rax, %rax
+; CHECK: notq %rax
+; CHECK: orq %rsi, %rax
+; CHECK: ret
+}
+
+define i64 @test11a(i64 %x, i64 %y) nounwind readnone ssp noredzone {
+ %cmp = icmp ne i64 %x, 0
+ %cond = select i1 %cmp, i64 -1, i64 %y
+ ret i64 %cond
+; CHECK: test11a:
+; CHECK: cmpq $1, %rdi
+; CHECK: sbbq %rax, %rax
+; CHECK: notq %rax
+; CHECK: orq %rsi, %rax
+; CHECK: ret
+}
+