aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/X86/jump_sign.ll
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-07-28 03:15:46 +0000
committerManman Ren <mren@apple.com>2012-07-28 03:15:46 +0000
commit43d9ab1812f7551844112f6f21cf3e487cb77385 (patch)
treec39e5e633e2e241c7eef2361789d89d72ede3b7a /test/CodeGen/X86/jump_sign.ll
parent4b72ada1f4c1c90ead331a650956e7b14450080e (diff)
downloadexternal_llvm-43d9ab1812f7551844112f6f21cf3e487cb77385.zip
external_llvm-43d9ab1812f7551844112f6f21cf3e487cb77385.tar.gz
external_llvm-43d9ab1812f7551844112f6f21cf3e487cb77385.tar.bz2
X86 Peephole: fix PR13475 in optimizeCompare.
It is possible that an instruction can use and update EFLAGS. When checking the safety, we should check the usage of EFLAGS first before declaring it is safe to optimize due to the update. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/jump_sign.ll')
-rw-r--r--test/CodeGen/X86/jump_sign.ll16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/CodeGen/X86/jump_sign.ll b/test/CodeGen/X86/jump_sign.ll
index 5fb6ee5..61792d3 100644
--- a/test/CodeGen/X86/jump_sign.ll
+++ b/test/CodeGen/X86/jump_sign.ll
@@ -214,3 +214,19 @@ entry:
%add. = select i1 %cmp, i32 %add, i32 0
ret i32 %add.
}
+; PR13475
+; If we have sub a, b and cmp b, a and the result of cmp is used
+; by sbb, we should not optimize cmp away.
+define i32 @q(i32 %j.4, i32 %w, i32 %el) {
+; CHECK: q:
+; CHECK: sub
+; CHECK: cmp
+; CHECK-NEXT: sbb
+ %tmp532 = add i32 %j.4, %w
+ %tmp533 = icmp ugt i32 %tmp532, %el
+ %tmp534 = icmp ult i32 %w, %el
+ %or.cond = and i1 %tmp533, %tmp534
+ %tmp535 = sub i32 %el, %w
+ %j.5 = select i1 %or.cond, i32 %tmp535, i32 %j.4
+ ret i32 %j.5
+}