diff options
author | Manman Ren <mren@apple.com> | 2012-07-06 17:36:20 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2012-07-06 17:36:20 +0000 |
commit | 2af66dc51a7a0f3490c7e89c636e4015431195cd (patch) | |
tree | 372cc52cf2cabe043a4c9c5937e62f758dd7b197 /test/CodeGen/X86/jump_sign.ll | |
parent | fd065bbed1d731b49b1b4a5c4c050ce461be80b4 (diff) | |
download | llvm-2af66dc51a7a0f3490c7e89c636e4015431195cd.tar.gz llvm-2af66dc51a7a0f3490c7e89c636e4015431195cd.tar.bz2 llvm-2af66dc51a7a0f3490c7e89c636e4015431195cd.tar.xz |
X86: peephole optimization to remove cmp instruction
For each Cmp, we check whether there is an earlier Sub which make Cmp
redundant. We handle the case where SUB operates on the same source operands as
Cmp, including the case where the two source operands are swapped.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/jump_sign.ll')
-rw-r--r-- | test/CodeGen/X86/jump_sign.ll | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/CodeGen/X86/jump_sign.ll b/test/CodeGen/X86/jump_sign.ll index 1bdf49ab43..567490b59e 100644 --- a/test/CodeGen/X86/jump_sign.ll +++ b/test/CodeGen/X86/jump_sign.ll @@ -83,6 +83,25 @@ entry: %cond = select i1 %cmp, i32 %sub, i32 0 ret i32 %cond } +; redundant cmp instruction +define i32 @l(i32 %a, i32 %b) nounwind { +entry: +; CHECK: l: +; CHECK-NOT: cmp + %cmp = icmp slt i32 %b, %a + %sub = sub nsw i32 %a, %b + %cond = select i1 %cmp, i32 %sub, i32 %a + ret i32 %cond +} +define i32 @m(i32 %a, i32 %b) nounwind { +entry: +; CHECK: m: +; CHECK-NOT: cmp + %cmp = icmp sgt i32 %a, %b + %sub = sub nsw i32 %a, %b + %cond = select i1 %cmp, i32 %b, i32 %sub + ret i32 %cond +} ; rdar://11540023 define i32 @n(i32 %x, i32 %y) nounwind { entry: |