aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-07-06 20:50:43 +0000
committerAndrew Trick <atrick@apple.com>2011-07-06 20:50:43 +0000
commit037d1c0c7e01cefeff7e538682c9a1e536e14030 (patch)
treed77b0b7bc5959c64864fefd70008d3b09678b47f /test/Transforms
parent0392a0431eeed3b230fc14fff438066470b06599 (diff)
downloadexternal_llvm-037d1c0c7e01cefeff7e538682c9a1e536e14030.zip
external_llvm-037d1c0c7e01cefeff7e538682c9a1e536e14030.tar.gz
external_llvm-037d1c0c7e01cefeff7e538682c9a1e536e14030.tar.bz2
indvars -disable-iv-rewrite: Added SimplifyCongruentIVs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134530 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/IndVarSimplify/no-iv-rewrite.ll50
-rw-r--r--test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll9
2 files changed, 55 insertions, 4 deletions
diff --git a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
index 639eb1d..9605670 100644
--- a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
+++ b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
@@ -270,3 +270,53 @@ cond_true:
return:
ret i32 %i.0
}
+
+; Eliminate the congruent phis j, k, and l.
+; Eliminate the redundant IV increments k.next and l.next.
+; Two phis should remain, one starting at %init, and one at %init1.
+; Two increments should remain, one by %step and one by %step1.
+; CHECK: loop:
+; CHECK: phi i32
+; CHECK: phi i32
+; CHECK-NOT: phi
+; CHECK: add i32
+; CHECK: add i32
+; CHECK-NOT: add
+; CHECK: return:
+;
+; Five live-outs should remain.
+; CHECK: lcssa = phi
+; CHECK: lcssa = phi
+; CHECK: lcssa = phi
+; CHECK: lcssa = phi
+; CHECK: lcssa = phi
+; CHECK-NOT: phi
+; CHECK: ret
+define i32 @isomorphic(i32 %init, i32 %step, i32 %lim) nounwind {
+entry:
+ %step1 = add i32 %step, 1
+ %init1 = add i32 %init, %step1
+ %l.0 = sub i32 %init1, %step1
+ br label %loop
+
+loop:
+ %ii = phi i32 [ %init1, %entry ], [ %ii.next, %loop ]
+ %i = phi i32 [ %init, %entry ], [ %ii, %loop ]
+ %j = phi i32 [ %init, %entry ], [ %j.next, %loop ]
+ %k = phi i32 [ %init1, %entry ], [ %k.next, %loop ]
+ %l = phi i32 [ %l.0, %entry ], [ %l.next, %loop ]
+ %ii.next = add i32 %ii, %step1
+ %j.next = add i32 %j, %step1
+ %k.next = add i32 %k, %step1
+ %l.step = add i32 %l, %step
+ %l.next = add i32 %l.step, 1
+ %cmp = icmp ne i32 %ii.next, %lim
+ br i1 %cmp, label %loop, label %return
+
+return:
+ %sum1 = add i32 %i, %j.next
+ %sum2 = add i32 %sum1, %k.next
+ %sum3 = add i32 %sum1, %l.step
+ %sum4 = add i32 %sum1, %l.next
+ ret i32 %sum4
+}
diff --git a/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll b/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll
index 0c8857f..ace74ff 100644
--- a/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll
+++ b/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll
@@ -1,9 +1,9 @@
-; RUN: opt < %s -indvars -instcombine -S | \
-; RUN: grep {store i32 0}
+; RUN: opt < %s -indvars -instcombine -S | FileCheck %s
+; RUN: opt < %s -indvars -disable-iv-rewrite -instcombine -S | FileCheck %s
+;
; Test that -indvars can reduce variable stride IVs. If it can reduce variable
-; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without
+; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without
; cycles, allowing the tmp.21 subtraction to be eliminated.
-; END.
define void @vnum_test8(i32* %data) {
entry:
@@ -20,6 +20,7 @@ no_exit.preheader: ; preds = %entry
%tmp.16 = getelementptr i32* %data, i32 %tmp.9 ; <i32*> [#uses=1]
br label %no_exit
+; CHECK: store i32 0
no_exit: ; preds = %no_exit, %no_exit.preheader
%iv.ui = phi i32 [ 0, %no_exit.preheader ], [ %iv..inc.ui, %no_exit ] ; <i32> [#uses=1]
%iv. = phi i32 [ %tmp.5, %no_exit.preheader ], [ %iv..inc, %no_exit ] ; <i32> [#uses=2]