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 | ed57984483b9268c30c71031fca07e71b985f169 (patch) | |
tree | 67d0c1880ab9bd3282fc83194b620a1abca336da /test/CodeGen/X86/select.ll | |
parent | af97f73ca03d16ffa069af65a494d0933665ce11 (diff) | |
download | llvm-ed57984483b9268c30c71031fca07e71b985f169.tar.gz llvm-ed57984483b9268c30c71031fca07e71b985f169.tar.bz2 llvm-ed57984483b9268c30c71031fca07e71b985f169.tar.xz |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156312 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/select.ll')
-rw-r--r-- | test/CodeGen/X86/select.ll | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/CodeGen/X86/select.ll b/test/CodeGen/X86/select.ll index 9adf4f9c05..c8d9345c40 100644 --- a/test/CodeGen/X86/select.ll +++ b/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 +} |