diff options
author | Manman Ren <mren@apple.com> | 2012-07-11 22:51:44 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2012-07-11 22:51:44 +0000 |
commit | 45ed19499b8f7025d9acf91cc37fbf6ea63abc4f (patch) | |
tree | a62c7eab67e6865b2e5c3f3b2e898f419a352fab /test | |
parent | 1d82115042c81793cc3d807a8136f7f0f475f083 (diff) | |
download | external_llvm-45ed19499b8f7025d9acf91cc37fbf6ea63abc4f.zip external_llvm-45ed19499b8f7025d9acf91cc37fbf6ea63abc4f.tar.gz external_llvm-45ed19499b8f7025d9acf91cc37fbf6ea63abc4f.tar.bz2 |
ARM: Fix optimizeCompare to correctly check safe condition.
It is safe if CPSR is killed or re-defined.
When we are done with the basic block, check whether CPSR is live-out.
Do not optimize away cmp if CPSR is live-out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160090 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/ARM/sub-cmp-peephole.ll | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/CodeGen/ARM/sub-cmp-peephole.ll b/test/CodeGen/ARM/sub-cmp-peephole.ll index c46c891..6fcbdee 100644 --- a/test/CodeGen/ARM/sub-cmp-peephole.ll +++ b/test/CodeGen/ARM/sub-cmp-peephole.ll @@ -44,3 +44,22 @@ entry: %sub. = select i1 %cmp, i32 %sub, i32 0 ret i32 %sub. } +; If CPSR is live-out, we can't remove cmp if there exists +; a swapped sub. +define i32 @j(i32 %a, i32 %b) nounwind { +entry: +; CHECK: j: +; CHECK: sub +; 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 +} |