summaryrefslogtreecommitdiff
path: root/test/Transforms/LoopReroll/reduction.ll
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2014-04-09 00:20:34 +0000
committerTom Stellard <thomas.stellard@amd.com>2014-04-09 00:20:34 +0000
commit29f0c4eafa67b97be70116306642fb75b144be41 (patch)
tree9dc62693a57d334145503a1e7829b4a374b631b0 /test/Transforms/LoopReroll/reduction.ll
parentf62454a661c5775fc687c2841afa1544aca4ab7e (diff)
downloadllvm-29f0c4eafa67b97be70116306642fb75b144be41.tar.gz
llvm-29f0c4eafa67b97be70116306642fb75b144be41.tar.bz2
llvm-29f0c4eafa67b97be70116306642fb75b144be41.tar.xz
Merging r198425:
------------------------------------------------------------------------ r198425 | dpeixott | 2014-01-03 12:20:01 -0500 (Fri, 03 Jan 2014) | 33 lines Fix loop rerolling pass failure with non-consant loop lower bound The loop rerolling pass was failing with an assertion failure from a failed cast on loops like this: void foo(int *A, int *B, int m, int n) { for (int i = m; i < n; i+=4) { A[i+0] = B[i+0] * 4; A[i+1] = B[i+1] * 4; A[i+2] = B[i+2] * 4; A[i+3] = B[i+3] * 4; } } The code was casting the SCEV-expanded code for the new induction variable to a phi-node. When the loop had a non-constant lower bound, the SCEV expander would end the code expansion with an add insted of a phi node and the cast would fail. It looks like the cast to a phi node was only needed to get the induction variable value coming from the backedge to compute the end of loop condition. This patch changes the loop reroller to compare the induction variable to the number of times the backedge is taken instead of the iteration count of the loop. In other words, we stop the loop when the current value of the induction variable == IterationCount-1. Previously, the comparison was comparing the induction variable value from the next iteration == IterationCount. This problem only seems to occur on 32-bit targets. For some reason, the loop is not rerolled on 64-bit targets. PR18290 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@205817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopReroll/reduction.ll')
-rw-r--r--test/Transforms/LoopReroll/reduction.ll4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/Transforms/LoopReroll/reduction.ll b/test/Transforms/LoopReroll/reduction.ll
index aed7670b66..c9991c723e 100644
--- a/test/Transforms/LoopReroll/reduction.ll
+++ b/test/Transforms/LoopReroll/reduction.ll
@@ -38,7 +38,7 @@ for.body: ; preds = %entry, %for.body
; CHECK: %0 = load i32* %arrayidx, align 4
; CHECK: %add = add nsw i32 %0, %r.029
; CHECK: %indvar.next = add i64 %indvar, 1
-; CHECK: %exitcond = icmp eq i64 %indvar.next, 400
+; CHECK: %exitcond = icmp eq i64 %indvar, 399
; CHECK: br i1 %exitcond, label %for.end, label %for.body
; CHECK: ret
@@ -83,7 +83,7 @@ for.body: ; preds = %entry, %for.body
; CHECK: %0 = load float* %arrayidx, align 4
; CHECK: %add = fadd float %0, %r.029
; CHECK: %indvar.next = add i64 %indvar, 1
-; CHECK: %exitcond = icmp eq i64 %indvar.next, 400
+; CHECK: %exitcond = icmp eq i64 %indvar, 399
; CHECK: br i1 %exitcond, label %for.end, label %for.body
; CHECK: ret