summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/jump_sign.ll
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-07-07 03:34:46 +0000
committerManman Ren <mren@apple.com>2012-07-07 03:34:46 +0000
commit2d4215f75949448d5207ec67b11878741a708fbe (patch)
treea41f6d1f7fa6643e1aee92b9aace18b4fc24d03d /test/CodeGen/X86/jump_sign.ll
parent845b4c2f0b2b3f0ec468ac863550b25708279180 (diff)
downloadllvm-2d4215f75949448d5207ec67b11878741a708fbe.tar.gz
llvm-2d4215f75949448d5207ec67b11878741a708fbe.tar.bz2
llvm-2d4215f75949448d5207ec67b11878741a708fbe.tar.xz
X86: Fix optimizeCompare to correctly check safe condition.
It is safe if EFLAGS is killed or re-defined. When we are done with the basic block, check whether EFLAGS is live-out. Do not optimize away cmp if EFLAGS is live-out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/jump_sign.ll')
-rw-r--r--test/CodeGen/X86/jump_sign.ll18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/CodeGen/X86/jump_sign.ll b/test/CodeGen/X86/jump_sign.ll
index 567490b59e..e84f49c8a1 100644
--- a/test/CodeGen/X86/jump_sign.ll
+++ b/test/CodeGen/X86/jump_sign.ll
@@ -102,6 +102,24 @@ entry:
%cond = select i1 %cmp, i32 %b, i32 %sub
ret i32 %cond
}
+; If EFLAGS is live-out, we can't remove cmp if there exists
+; a swapped sub.
+define i32 @l2(i32 %a, i32 %b) nounwind {
+entry:
+; CHECK: l2:
+; CHECK: cmp
+ %cmp = icmp eq i32 %b, %a
+ %sub = sub nsw i32 %a, %b
+ br i1 %cmp, label %if.then, label %if.else
+
+if.then:
+ %cmp2 = icmp sgt i32 %b, %a
+ %sel = select i1 %cmp2, i32 %sub, i32 %a
+ ret i32 %sel
+
+if.else:
+ ret i32 %sub
+}
; rdar://11540023
define i32 @n(i32 %x, i32 %y) nounwind {
entry: