diff options
author | Chen Li <meloli87@gmail.com> | 2015-09-26 03:26:47 +0000 |
---|---|---|
committer | Chen Li <meloli87@gmail.com> | 2015-09-26 03:26:47 +0000 |
commit | 7452d9565665ee840a6cc390b2b92757d201b72b (patch) | |
tree | 5c3ed7826488d94f7be2962e5535ea06670878f2 /llvm/test/Transforms/InstCombine/icmp-range.ll | |
parent | d44901f21bbd71fab5d61c88e14d3233a821a110 (diff) | |
download | bcm5719-llvm-7452d9565665ee840a6cc390b2b92757d201b72b.tar.gz bcm5719-llvm-7452d9565665ee840a6cc390b2b92757d201b72b.zip |
[Bug 24848] Use range metadata to constant fold comparisons between two values
Summary:
This is the second part of fixing bug 24848 https://llvm.org/bugs/show_bug.cgi?id=24848.
If both operands of a comparison have range metadata, they should be used to constant fold the comparison.
Reviewers: sanjoy, hfinkel
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D13177
llvm-svn: 248650
Diffstat (limited to 'llvm/test/Transforms/InstCombine/icmp-range.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp-range.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp-range.ll b/llvm/test/Transforms/InstCombine/icmp-range.ll index effcc381697..f035683170e 100644 --- a/llvm/test/Transforms/InstCombine/icmp-range.ll +++ b/llvm/test/Transforms/InstCombine/icmp-range.ll @@ -111,8 +111,40 @@ define i1 @test_multi_range2(i32* nocapture readonly %arg) { ret i1 %rval } +; Values' ranges overlap each other, so it can not be simplified. +define i1 @test_two_ranges(i32* nocapture readonly %arg1, i32* nocapture readonly %arg2) { +; CHECK-LABEL: test_two_ranges +; CHECK: icmp ult i32 %val2, %val1 + %val1 = load i32, i32* %arg1, !range !5 + %val2 = load i32, i32* %arg2, !range !6 + %rval = icmp ult i32 %val2, %val1 + ret i1 %rval +} + +; Values' ranges do not overlap each other, so it can simplified to false. +define i1 @test_two_ranges2(i32* nocapture readonly %arg1, i32* nocapture readonly %arg2) { +; CHECK-LABEL: test_two_ranges2 +; CHECK: ret i1 false + %val1 = load i32, i32* %arg1, !range !0 + %val2 = load i32, i32* %arg2, !range !6 + %rval = icmp ult i32 %val2, %val1 + ret i1 %rval +} + +; Values' ranges do not overlap each other, so it can simplified to true. +define i1 @test_two_ranges3(i32* nocapture readonly %arg1, i32* nocapture readonly %arg2) { +; CHECK-LABEL: test_two_ranges3 +; CHECK: ret i1 true + %val1 = load i32, i32* %arg1, !range !0 + %val2 = load i32, i32* %arg2, !range !6 + %rval = icmp ugt i32 %val2, %val1 + ret i1 %rval +} + !0 = !{i32 1, i32 6} !1 = !{i32 0, i32 6} !2 = !{i8 0, i8 1} !3 = !{i8 0, i8 6} !4 = !{i32 1, i32 6, i32 8, i32 10} +!5 = !{i32 5, i32 10} +!6 = !{i32 8, i32 16} |