diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2014-10-10 21:22:34 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2014-10-10 21:22:34 +0000 |
commit | 1f05c51e5ecdf6e35a58689aead4dc162850914a (patch) | |
tree | 5424ae2c0072a6571b4c38fe04e159cbc4004b88 /llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll | |
parent | 38811ccb97cb4fd5a4b9a9e830dcff7c79066acf (diff) | |
download | bcm5719-llvm-1f05c51e5ecdf6e35a58689aead4dc162850914a.tar.gz bcm5719-llvm-1f05c51e5ecdf6e35a58689aead4dc162850914a.zip |
This patch teaches ScalarEvolution to pick and use !range metadata.
It also makes it more aggressive in querying range information by
adding a call to isKnownPredicateWithRanges to
isLoopBackedgeGuardedByCond and isLoopEntryGuardedByCond.
phabricator: http://reviews.llvm.org/D5638
Reviewed by: atrick, hfinkel
llvm-svn: 219532
Diffstat (limited to 'llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll')
-rw-r--r-- | llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll b/llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll new file mode 100644 index 00000000000..2f6dcd0dad5 --- /dev/null +++ b/llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll @@ -0,0 +1,37 @@ +; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s + +define i32 @slt_trip_count_with_range(i32 *%ptr0, i32 *%ptr1) { +; CHECK-LABEL: slt_trip_count_with_range + entry: + %limit = load i32* %ptr0, !range !0 + br label %loop + + loop: +; CHECK: Loop %loop: max backedge-taken count is 98 + %index = phi i32 [ 0, %entry ], [ %index.inc, %loop ] + %index.inc = add i32 %index, 1 + %continue = icmp slt i32 %index.inc, %limit + br i1 %continue, label %loop, label %loop.exit + + loop.exit: + ret i32 0 +} + +define i32 @ult_trip_count_with_range(i32 *%ptr0, i32 *%ptr1) { +; CHECK-LABEL: ult_trip_count_with_range + entry: + %limit = load i32* %ptr0, !range !0 + br label %loop + + loop: +; CHECK: Loop %loop: max backedge-taken count is 98 + %index = phi i32 [ 0, %entry ], [ %index.inc, %loop ] + %index.inc = add i32 %index, 1 + %continue = icmp ult i32 %index.inc, %limit + br i1 %continue, label %loop, label %loop.exit + + loop.exit: + ret i32 0 +} + +!0 = metadata !{i32 1, i32 100} |