diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-05-14 20:16:28 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-05-14 20:16:28 +0000 |
| commit | 2d6c023576d78af7c74a3ecda5bb53a65ad682f0 (patch) | |
| tree | a51684eda4a13e98a350f8b6164d0fa64744f356 /llvm/test/Transforms | |
| parent | 1a3a07471fdd94d000f2c83c20acfcab55749a92 (diff) | |
| download | bcm5719-llvm-2d6c023576d78af7c74a3ecda5bb53a65ad682f0.tar.gz bcm5719-llvm-2d6c023576d78af7c74a3ecda5bb53a65ad682f0.zip | |
InstSimplify: Optimize signed icmp of -(zext V)
Summary:
We know that -(zext V) will always be <= zero, simplify signed icmps
that have these.
Uncovered using http://www.cs.utah.edu/~regehr/souper/
Reviewers: nicholas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D3754
llvm-svn: 208809
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/compare.ll | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll index ee6be0458cb..76cff902c96 100644 --- a/llvm/test/Transforms/InstSimplify/compare.ll +++ b/llvm/test/Transforms/InstSimplify/compare.ll @@ -757,3 +757,63 @@ define <4 x i8> @vectorselectfold2(<4 x i8> %a, <4 x i8> %b) { ; CHECK-LABEL: @vectorselectfold ; CHECK-NEXT: ret <4 x i8> %a } + +define i1 @compare_always_true_slt(i16 %a) { + %1 = zext i16 %a to i32 + %2 = sub nsw i32 0, %1 + %3 = icmp slt i32 %2, 1 + ret i1 %3 + +; CHECK-LABEL: @compare_always_true_slt +; CHECK-NEXT: ret i1 true +} + +define i1 @compare_always_true_sle(i16 %a) { + %1 = zext i16 %a to i32 + %2 = sub nsw i32 0, %1 + %3 = icmp sle i32 %2, 0 + ret i1 %3 + +; CHECK-LABEL: @compare_always_true_sle +; CHECK-NEXT: ret i1 true +} + +define i1 @compare_always_false_sgt(i16 %a) { + %1 = zext i16 %a to i32 + %2 = sub nsw i32 0, %1 + %3 = icmp sgt i32 %2, 0 + ret i1 %3 + +; CHECK-LABEL: @compare_always_false_sgt +; CHECK-NEXT: ret i1 false +} + +define i1 @compare_always_false_sge(i16 %a) { + %1 = zext i16 %a to i32 + %2 = sub nsw i32 0, %1 + %3 = icmp sge i32 %2, 1 + ret i1 %3 + +; CHECK-LABEL: @compare_always_false_sge +; CHECK-NEXT: ret i1 false +} + +define i1 @compare_always_false_eq(i16 %a) { + %1 = zext i16 %a to i32 + %2 = sub nsw i32 0, %1 + %3 = icmp eq i32 %2, 1 + ret i1 %3 + +; CHECK-LABEL: @compare_always_false_eq +; CHECK-NEXT: ret i1 false +} + +define i1 @compare_always_false_ne(i16 %a) { + %1 = zext i16 %a to i32 + %2 = sub nsw i32 0, %1 + %3 = icmp ne i32 %2, 1 + ret i1 %3 + +; CHECK-LABEL: @compare_always_false_ne +; CHECK-NEXT: ret i1 true +} |

