summaryrefslogtreecommitdiff
path: root/test/Transforms/LoopStrengthReduce
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2014-02-15 17:11:56 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2014-02-15 17:11:56 +0000
commite67254860230c58a5de34578354a4d1d78c87e83 (patch)
treefd08513cbe9cebcc9f8622d8a725275294201eee /test/Transforms/LoopStrengthReduce
parent4b3ec1763c22130fb91380413a8c3ddbdf044c3e (diff)
downloadllvm-e67254860230c58a5de34578354a4d1d78c87e83.tar.gz
llvm-e67254860230c58a5de34578354a4d1d78c87e83.tar.bz2
llvm-e67254860230c58a5de34578354a4d1d78c87e83.tar.xz
SCEVExpander: Try hard not to create derived induction variables in other loops
During LSR of one loop we can run into a situation where we have to expand the start of a recurrence of a loop induction variable in this loop. This start value is a value derived of the induction variable of a preceeding loop. SCEV has cannonicalized this value to a different recurrence than the recurrence of the preceeding loop's induction variable (the type and/or step direction) has changed). When we come to instantiate this SCEV we created a second induction variable in this preceeding loop. This patch tries to base such derived induction variables of the preceeding loop's induction variable. This helps twolf on arm and seems to help scimark2 on x86. radar://15970709 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201465 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopStrengthReduce')
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/no_superflous_induction_vars.ll50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/Transforms/LoopStrengthReduce/X86/no_superflous_induction_vars.ll b/test/Transforms/LoopStrengthReduce/X86/no_superflous_induction_vars.ll
new file mode 100644
index 0000000000..5506994724
--- /dev/null
+++ b/test/Transforms/LoopStrengthReduce/X86/no_superflous_induction_vars.ll
@@ -0,0 +1,50 @@
+; RUN: opt -S -loop-reduce -mcpu=corei7-avx -mtriple=x86_64-apple-macosx < %s | FileCheck %s
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @indvar_expansion(i8* nocapture readonly %rowsptr) {
+entry:
+ br label %for.cond
+
+; SCEVExpander used to create induction variables in the loop %for.cond while
+; expanding the recurrence start value of loop strength reduced values from
+; %vector.body.
+
+; CHECK-LABEL: indvar_expansion
+; CHECK: for.cond:
+; CHECK-NOT: phi i3
+; CHECK: br i1 {{.+}}, label %for.cond
+
+for.cond:
+ %indvars.iv44 = phi i64 [ %indvars.iv.next45, %for.cond ], [ 0, %entry ]
+ %cmp = icmp eq i8 undef, 0
+ %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
+ br i1 %cmp, label %for.cond, label %for.cond2
+
+for.cond2:
+ br i1 undef, label %for.cond2, label %for.body14.lr.ph
+
+for.body14.lr.ph:
+ %sext = shl i64 %indvars.iv44, 32
+ %0 = ashr exact i64 %sext, 32
+ %1 = sub i64 undef, %indvars.iv44
+ %2 = and i64 %1, 4294967295
+ %3 = add i64 %2, 1
+ %fold = add i64 %1, 1
+ %n.mod.vf = and i64 %fold, 7
+ %n.vec = sub i64 %3, %n.mod.vf
+ %end.idx.rnd.down = add i64 %n.vec, %0
+ br label %vector.body
+
+vector.body:
+ %index = phi i64 [ %index.next, %vector.body ], [ %0, %for.body14.lr.ph ]
+ %4 = getelementptr inbounds i8* %rowsptr, i64 %index
+ %5 = bitcast i8* %4 to <4 x i8>*
+ %wide.load = load <4 x i8>* %5, align 1
+ %index.next = add i64 %index, 8
+ %6 = icmp eq i64 %index.next, %end.idx.rnd.down
+ br i1 %6, label %for.end24, label %vector.body
+
+for.end24:
+ ret void
+}