diff options
author | Manman Ren <mren@apple.com> | 2012-05-07 18:06:23 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2012-05-07 18:06:23 +0000 |
commit | ef4e0479ec17bccff0c1c491db1d346c13d951cd (patch) | |
tree | ec6faf0b445d4bffbbe4fac65b84ef43f8391169 /llvm/test/CodeGen/X86/select.ll | |
parent | f463abc0e71ce0ba4a12f63aa8d2fc85dd3682f7 (diff) | |
download | bcm5719-llvm-ef4e0479ec17bccff0c1c491db1d346c13d951cd.tar.gz bcm5719-llvm-ef4e0479ec17bccff0c1c491db1d346c13d951cd.zip |
X86: optimization for -(x != 0)
This patch will optimize -(x != 0) on X86
FROM
cmpl $0x01,%edi
sbbl %eax,%eax
notl %eax
TO
negl %edi
sbbl %eax %eax
In order to generate negl, I added patterns in Target/X86/X86InstrCompiler.td:
def : Pat<(X86sub_flag 0, GR32:$src), (NEG32r GR32:$src)>;
rdar: 10961709
llvm-svn: 156312
Diffstat (limited to 'llvm/test/CodeGen/X86/select.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/select.ll | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/select.ll b/llvm/test/CodeGen/X86/select.ll index 9adf4f9c050..c8d9345c400 100644 --- a/llvm/test/CodeGen/X86/select.ll +++ b/llvm/test/CodeGen/X86/select.ll @@ -218,3 +218,33 @@ define i32 @test14(i32 %a, i32 %b) nounwind { ; CHECK-NEXT: ret } +; rdar://10961709 +define i32 @test15(i32 %x) nounwind { +entry: + %cmp = icmp ne i32 %x, 0 + %sub = sext i1 %cmp to i32 + ret i32 %sub +; CHECK: test15: +; CHECK: negl +; CHECK: sbbl +} + +define i64 @test16(i64 %x) nounwind uwtable readnone ssp { +entry: + %cmp = icmp ne i64 %x, 0 + %conv1 = sext i1 %cmp to i64 + ret i64 %conv1 +; CHECK: test16: +; CHECK: negq +; CHECK: sbbq +} + +define i16 @test17(i16 %x) nounwind { +entry: + %cmp = icmp ne i16 %x, 0 + %sub = sext i1 %cmp to i16 + ret i16 %sub +; CHECK: test17: +; CHECK: negw +; CHECK: sbbw +} |