diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2007-12-20 07:21:11 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2007-12-20 07:21:11 +0000 |
commit | 103e1a311809edd162463a2dc21edad2dd7251ba (patch) | |
tree | 700216904e4273cee9a865b176690ae7a0265456 /test | |
parent | 46f1a8797cfc9ff2a64438060deaed5e8f1f9a6b (diff) | |
download | external_llvm-103e1a311809edd162463a2dc21edad2dd7251ba.zip external_llvm-103e1a311809edd162463a2dc21edad2dd7251ba.tar.gz external_llvm-103e1a311809edd162463a2dc21edad2dd7251ba.tar.bz2 |
Implement review feedback, including additional transforms
(icmp slt (sub A B) 1) -> (icmp sle A B)
icmp sgt (sub A B) -1) -> (icmp sge A B)
and add testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45256 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/InstCombine/2007-12-19-IcmpSub.ll | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/2007-12-19-IcmpSub.ll b/test/Transforms/InstCombine/2007-12-19-IcmpSub.ll new file mode 100644 index 0000000..ecb5e6e --- /dev/null +++ b/test/Transforms/InstCombine/2007-12-19-IcmpSub.ll @@ -0,0 +1,25 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {sub} + +define i32 @foo(i32 %a) { +entry: + %tmp2 = sub i32 99, %a ; <i32> [#uses=1] + %tmp3 = icmp sgt i32 %tmp2, -1 ; <i1> [#uses=1] + %retval = select i1 %tmp3, i32 %a, i32 0 ; <i32> [#uses=1] + ret i32 %retval +} + +define i32 @bar(i32 %a) { +entry: + %tmp2 = sub i32 99, %a ; <i32> [#uses=1] + %tmp3 = icmp sge i32 %tmp2, 0; <i1> [#uses=1] + %retval = select i1 %tmp3, i32 %a, i32 0 ; <i32> [#uses=1] + ret i32 %retval +} + +define i32 @baz(i32 %a) { +entry: + %tmp2 = sub i32 99, %a ; <i32> [#uses=1] + %tmp3 = icmp slt i32 %tmp2, 1 ; <i1> [#uses=1] + %retval = select i1 %tmp3, i32 %a, i32 0 ; <i32> [#uses=1] + ret i32 %retval +}
\ No newline at end of file |