summaryrefslogtreecommitdiff
path: root/test/Transforms/CorrelatedValuePropagation
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-03-02 15:34:43 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-03-02 15:34:43 +0000
commit8979e5f3725c05bd7120890e39399213fd08f83e (patch)
tree8fd22ad3d8f049fb32881a8103e5707c037c0dce /test/Transforms/CorrelatedValuePropagation
parent0c7374d87e6bf002028cd19f8ae9547927c9c645 (diff)
downloadllvm-8979e5f3725c05bd7120890e39399213fd08f83e.tar.gz
llvm-8979e5f3725c05bd7120890e39399213fd08f83e.tar.bz2
llvm-8979e5f3725c05bd7120890e39399213fd08f83e.tar.xz
LVI: Recognize the form instcombine canonicalizes range checks into when forming constant ranges.
This could probably be made a lot smarter, but this is a common case and doesn't require LVI to scan a lot of code. With this change CVP can optimize away the "shift == 0" case in Hashing.h that only gets hit when "shift" is in a range not containing 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/CorrelatedValuePropagation')
-rw-r--r--test/Transforms/CorrelatedValuePropagation/range.ll43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/Transforms/CorrelatedValuePropagation/range.ll b/test/Transforms/CorrelatedValuePropagation/range.ll
new file mode 100644
index 0000000000..9b70ed200e
--- /dev/null
+++ b/test/Transforms/CorrelatedValuePropagation/range.ll
@@ -0,0 +1,43 @@
+; RUN: opt -correlated-propagation -S < %s | FileCheck %s
+
+declare i32 @foo()
+
+define i32 @test1(i32 %a) nounwind {
+ %a.off = add i32 %a, -8
+ %cmp = icmp ult i32 %a.off, 8
+ br i1 %cmp, label %then, label %else
+
+then:
+ %dead = icmp eq i32 %a, 7
+ br i1 %dead, label %end, label %else
+
+else:
+ ret i32 1
+
+end:
+ ret i32 2
+
+; CHECK: @test1
+; CHECK: then:
+; CHECK-NEXT: br i1 false, label %end, label %else
+}
+
+define i32 @test2(i32 %a) nounwind {
+ %a.off = add i32 %a, -8
+ %cmp = icmp ult i32 %a.off, 8
+ br i1 %cmp, label %then, label %else
+
+then:
+ %dead = icmp ugt i32 %a, 15
+ br i1 %dead, label %end, label %else
+
+else:
+ ret i32 1
+
+end:
+ ret i32 2
+
+; CHECK: @test2
+; CHECK: then:
+; CHECK-NEXT: br i1 false, label %end, label %else
+}