diff options
author | Dan Gohman <gohman@apple.com> | 2010-06-29 23:43:06 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-06-29 23:43:06 +0000 |
commit | 1104645eefa134ff3dd2c911d2aaa0dffb38f59f (patch) | |
tree | 8e15e4236a848e03743b3247901c765b8b63b0d9 /test/Transforms/IndVarSimplify/tripcount_compute.ll | |
parent | 07d317711781d8c9268f7d6afcf1ba7eadf1d127 (diff) | |
download | external_llvm-1104645eefa134ff3dd2c911d2aaa0dffb38f59f.zip external_llvm-1104645eefa134ff3dd2c911d2aaa0dffb38f59f.tar.gz external_llvm-1104645eefa134ff3dd2c911d2aaa0dffb38f59f.tar.bz2 |
Fix ScalarEvolution's tripcount computation for chains of loops
where each loop's induction variable's start value is the exit
value of a preceding loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/IndVarSimplify/tripcount_compute.ll')
-rw-r--r-- | test/Transforms/IndVarSimplify/tripcount_compute.ll | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/test/Transforms/IndVarSimplify/tripcount_compute.ll b/test/Transforms/IndVarSimplify/tripcount_compute.ll index 6eaa4c5..8835b96 100644 --- a/test/Transforms/IndVarSimplify/tripcount_compute.ll +++ b/test/Transforms/IndVarSimplify/tripcount_compute.ll @@ -1,9 +1,12 @@ +; RUN: opt < %s -indvars -S | FileCheck %s + ; These tests ensure that we can compute the trip count of various forms of ; loops. If the trip count of the loop is computable, then we will know what ; the exit value of the loop will be for some value, allowing us to substitute ; it directly into users outside of the loop, making the loop dead. -; -; RUN: opt < %s -indvars -loop-deletion -simplifycfg -S | not grep br + +; CHECK: @linear_setne +; CHECK: ret i32 100 define i32 @linear_setne() { entry: @@ -19,6 +22,9 @@ loopexit: ; preds = %loop ret i32 %i } +; CHECK: @linear_setne_2 +; CHECK: ret i32 100 + define i32 @linear_setne_2() { entry: br label %loop @@ -33,6 +39,9 @@ loopexit: ; preds = %loop ret i32 %i } +; CHECK: @linear_setne_overflow +; CHECK: ret i32 0 + define i32 @linear_setne_overflow() { entry: br label %loop @@ -47,6 +56,9 @@ loopexit: ; preds = %loop ret i32 %i } +; CHECK: @linear_setlt +; CHECK: ret i32 100 + define i32 @linear_setlt() { entry: br label %loop @@ -61,6 +73,9 @@ loopexit: ; preds = %loop ret i32 %i } +; CHECK: @quadratic_setlt +; CHECK: ret i32 34 + define i32 @quadratic_setlt() { entry: br label %loop @@ -76,6 +91,9 @@ loopexit: ; preds = %loop ret i32 %i } +; CHECK: @chained +; CHECK: ret i32 200 + define i32 @chained() { entry: br label %loop @@ -98,3 +116,47 @@ loop2: ; preds = %loop2, %loopexit loopexit2: ; preds = %loop2 ret i32 %j } + +; CHECK: @chained4 +; CHECK: ret i32 400 + +define i32 @chained4() { +entry: + br label %loop + +loop: ; preds = %loop, %entry + %i = phi i32 [ 0, %entry ], [ %i.next, %loop ] ; <i32> [#uses=3] + %i.next = add i32 %i, 1 ; <i32> [#uses=1] + %c = icmp ne i32 %i.next, 100 ; <i1> [#uses=1] + br i1 %c, label %loop, label %loopexit + +loopexit: ; preds = %loop + br label %loop2 + +loop2: ; preds = %loop2, %loopexit + %j = phi i32 [ %i.next, %loopexit ], [ %j.next, %loop2 ] ; <i32> [#uses=3] + %j.next = add i32 %j, 1 ; <i32> [#uses=1] + %c2 = icmp ne i32 %j.next, 200 ; <i1> [#uses=1] + br i1 %c2, label %loop2, label %loopexit2 + +loopexit2: ; preds = %loop + br label %loop8 + +loop8: ; preds = %loop2, %loopexit + %k = phi i32 [ %j.next, %loopexit2 ], [ %k.next, %loop8 ] ; <i32> [#uses=3] + %k.next = add i32 %k, 1 ; <i32> [#uses=1] + %c8 = icmp ne i32 %k.next, 300 ; <i1> [#uses=1] + br i1 %c8, label %loop8, label %loopexit8 + +loopexit8: ; preds = %loop2 + br label %loop9 + +loop9: ; preds = %loop2, %loopexit + %l = phi i32 [ %k.next, %loopexit8 ], [ %l.next, %loop9 ] ; <i32> [#uses=3] + %l.next = add i32 %l, 1 ; <i32> [#uses=1] + %c9 = icmp ne i32 %l.next, 400 ; <i1> [#uses=1] + br i1 %c9, label %loop9, label %loopexit9 + +loopexit9: ; preds = %loop2 + ret i32 %l.next +} |