summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/CorrelatedValuePropagation/range.ll
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2016-08-09 14:50:08 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2016-08-09 14:50:08 +0000
commitc710a461b57e0540a97b123691d8dbac443d2a17 (patch)
treed3ef5056219822aa11e60f74ca1fa9978f3ff3ff /llvm/test/Transforms/CorrelatedValuePropagation/range.ll
parent83bbd5731bcb88374b400d349a98711d71c2ec14 (diff)
downloadbcm5719-llvm-c710a461b57e0540a97b123691d8dbac443d2a17.tar.gz
bcm5719-llvm-c710a461b57e0540a97b123691d8dbac443d2a17.zip
[LVI] Make LVI smarter about comparisons with non-constants
Make LVI smarter about comparisons with a non-constant. For example, a s< b constraints a to be in [INT_MIN, INT_MAX) range. This is a part of https://llvm.org/bugs/show_bug.cgi?id=28620 fix. Reviewed By: sanjoy Differential Revision: https://reviews.llvm.org/D23205 llvm-svn: 278122
Diffstat (limited to 'llvm/test/Transforms/CorrelatedValuePropagation/range.ll')
-rw-r--r--llvm/test/Transforms/CorrelatedValuePropagation/range.ll112
1 files changed, 112 insertions, 0 deletions
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/range.ll b/llvm/test/Transforms/CorrelatedValuePropagation/range.ll
index 8ca171a286c..f8ad6bd3bbf 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/range.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/range.ll
@@ -203,3 +203,115 @@ define i1 @test11() {
next:
ret i1 %test
}
+
+define i32 @test12(i32 %a, i32 %b) {
+; CHECK-LABEL: @test12(
+; CHECK: then:
+; CHECK-NEXT: br i1 false, label %end, label %else
+ %cmp = icmp ult i32 %a, %b
+ br i1 %cmp, label %then, label %else
+
+then:
+ %dead = icmp eq i32 %a, -1
+ br i1 %dead, label %end, label %else
+
+else:
+ ret i32 1
+
+end:
+ ret i32 2
+}
+
+define i32 @test12_swap(i32 %a, i32 %b) {
+; CHECK-LABEL: @test12_swap(
+; CHECK: then:
+; CHECK-NEXT: br i1 false, label %end, label %else
+ %cmp = icmp ugt i32 %b, %a
+ br i1 %cmp, label %then, label %else
+
+then:
+ %dead = icmp eq i32 %a, -1
+ br i1 %dead, label %end, label %else
+
+else:
+ ret i32 1
+
+end:
+ ret i32 2
+}
+
+define i32 @test12_neg(i32 %a, i32 %b) {
+; The same as @test12 but the second check is on the false path
+; CHECK-LABEL: @test12_neg(
+; CHECK: else:
+; CHECK-NEXT: %alive = icmp eq i32 %a, -1
+ %cmp = icmp ult i32 %a, %b
+ br i1 %cmp, label %then, label %else
+
+else:
+ %alive = icmp eq i32 %a, -1
+ br i1 %alive, label %end, label %then
+
+then:
+ ret i32 1
+
+end:
+ ret i32 2
+}
+
+define i32 @test12_signed(i32 %a, i32 %b) {
+; The same as @test12 but with signed comparison
+; CHECK-LABEL: @test12_signed(
+; CHECK: then:
+; CHECK-NEXT: br i1 false, label %end, label %else
+ %cmp = icmp slt i32 %a, %b
+ br i1 %cmp, label %then, label %else
+
+then:
+ %dead = icmp eq i32 %a, 2147483647
+ br i1 %dead, label %end, label %else
+
+else:
+ ret i32 1
+
+end:
+ ret i32 2
+}
+
+define i32 @test13(i32 %a, i32 %b) {
+; CHECK-LABEL: @test13(
+; CHECK: then:
+; CHECK-NEXT: br i1 false, label %end, label %else
+ %a.off = add i32 %a, -8
+ %cmp = icmp ult i32 %a.off, %b
+ 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
+}
+
+define i32 @test13_swap(i32 %a, i32 %b) {
+; CHECK-LABEL: @test13_swap(
+; CHECK: then:
+; CHECK-NEXT: br i1 false, label %end, label %else
+ %a.off = add i32 %a, -8
+ %cmp = icmp ugt i32 %b, %a.off
+ 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
+}
OpenPOWER on IntegriCloud