summaryrefslogtreecommitdiff
path: root/test/Transforms/IndVarSimplify/lftr-promote.ll
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-16 17:34:36 +0000
committerDan Gohman <gohman@apple.com>2009-07-16 17:34:36 +0000
commit850f791abc3ffc3f5fb73712df2f4a2d4cc0b998 (patch)
tree32f8fb7aba192983e91dca901e54d371373117c6 /test/Transforms/IndVarSimplify/lftr-promote.ll
parent358ab1dbb016c50528ada714fa400c821438f2ee (diff)
downloadllvm-850f791abc3ffc3f5fb73712df2f4a2d4cc0b998.tar.gz
llvm-850f791abc3ffc3f5fb73712df2f4a2d4cc0b998.tar.bz2
llvm-850f791abc3ffc3f5fb73712df2f4a2d4cc0b998.tar.xz
Fill in some holes in ScalarEvolution's loop iteration condition
analysis. This allows indvars to emit a simpler loop trip count expression. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76085 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/IndVarSimplify/lftr-promote.ll')
-rw-r--r--test/Transforms/IndVarSimplify/lftr-promote.ll38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/Transforms/IndVarSimplify/lftr-promote.ll b/test/Transforms/IndVarSimplify/lftr-promote.ll
new file mode 100644
index 0000000000..b2cb770dd6
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/lftr-promote.ll
@@ -0,0 +1,38 @@
+; RUN: llvm-as < %s | opt -indvars | llvm-dis | grep add | count 1
+
+; Indvars should be able to compute the exit value of this loop
+; without any additional arithmetic. The only add needed should
+; be the canonical IV increment.
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+
+define void @foo(double* %p, i32 %n) nounwind {
+entry:
+ %0 = icmp sgt i32 %n, 0 ; <i1> [#uses=1]
+ br i1 %0, label %bb.nph, label %return
+
+bb.nph: ; preds = %entry
+ br label %bb2
+
+bb2: ; preds = %bb3, %bb.nph
+ %i.01 = phi i32 [ %7, %bb3 ], [ 0, %bb.nph ] ; <i32> [#uses=3]
+ %1 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
+ %2 = getelementptr double* %p, i64 %1 ; <double*> [#uses=1]
+ %3 = load double* %2, align 8 ; <double> [#uses=1]
+ %4 = fmul double %3, 1.100000e+00 ; <double> [#uses=1]
+ %5 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
+ %6 = getelementptr double* %p, i64 %5 ; <double*> [#uses=1]
+ store double %4, double* %6, align 8
+ %7 = add i32 %i.01, 1 ; <i32> [#uses=2]
+ br label %bb3
+
+bb3: ; preds = %bb2
+ %8 = icmp slt i32 %7, %n ; <i1> [#uses=1]
+ br i1 %8, label %bb2, label %bb3.return_crit_edge
+
+bb3.return_crit_edge: ; preds = %bb3
+ br label %return
+
+return: ; preds = %bb3.return_crit_edge, %entry
+ ret void
+}