diff options
| author | Michael Zolotukhin <mzolotukhin@apple.com> | 2016-05-13 21:23:25 +0000 | 
|---|---|---|
| committer | Michael Zolotukhin <mzolotukhin@apple.com> | 2016-05-13 21:23:25 +0000 | 
| commit | 963a6d9c69c9d18b57543f751d5de05f9578dc1d (patch) | |
| tree | 4ac69e9a4f110f3c5695f1f4c7d41b202501ab82 /llvm/test | |
| parent | 16cfe9aa062cfd613684a5fdffc87ed7f98ec850 (diff) | |
| download | bcm5719-llvm-963a6d9c69c9d18b57543f751d5de05f9578dc1d.tar.gz bcm5719-llvm-963a6d9c69c9d18b57543f751d5de05f9578dc1d.zip | |
Revert "Revert "[Unroll] Implement a conservative and monotonically increasing cost tracking system during the full unroll heuristic analysis that avoids counting any instruction cost until that instruction becomes "live" through a side-effect or use outside the...""
This reverts commit r269395.
Try to reapply with a fix from chapuni.
llvm-svn: 269486
Diffstat (limited to 'llvm/test')
3 files changed, 40 insertions, 2 deletions
| diff --git a/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-2.ll b/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-2.ll index 5df48e8c380..f62141d9c37 100644 --- a/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-2.ll +++ b/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-threshold=10  -unroll-percent-dynamic-cost-saved-threshold=50 -unroll-dynamic-cost-savings-discount=90 | FileCheck %s +; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-threshold=10  -unroll-percent-dynamic-cost-saved-threshold=70 -unroll-dynamic-cost-savings-discount=90 | FileCheck %s  target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"  @unknown_global = internal unnamed_addr global [9 x i32] [i32 0, i32 -1, i32 0, i32 -1, i32 5, i32 -1, i32 0, i32 -1, i32 0], align 16 diff --git a/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-dce.ll b/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-dce.ll new file mode 100644 index 00000000000..6ee73b6fe4f --- /dev/null +++ b/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-dce.ll @@ -0,0 +1,38 @@ +; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=100 -unroll-dynamic-cost-savings-discount=1000 -unroll-threshold=10 -unroll-percent-dynamic-cost-saved-threshold=60 | FileCheck %s +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" + +@known_constant = internal unnamed_addr constant [10 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 + +; If a load becomes a constant after loop unrolling, we sometimes can simplify +; CFG. This test verifies that we handle such cases. +; After one operand in an instruction is constant-folded and the +; instruction is simplified, the other operand might become dead. +; In this test we have:: +; for i in 1..10: +;   r += A[i] * B[i] +; A[i] is 0 almost at every iteration, so there is no need in loading B[i] at +; all. + + +; CHECK-LABEL: @unroll_dce +; CHECK-NOT:   br i1 %exitcond, label %for.end, label %for.body +define i32 @unroll_dce(i32* noalias nocapture readonly %b) { +entry: +  br label %for.body + +for.body:                                         ; preds = %for.body, %entry +  %iv.0 = phi i64 [ 0, %entry ], [ %iv.1, %for.body ] +  %r.0 = phi i32 [ 0, %entry ], [ %r.1, %for.body ] +  %arrayidx1 = getelementptr inbounds [10 x i32], [10 x i32]* @known_constant, i64 0, i64 %iv.0 +  %x1 = load i32, i32* %arrayidx1, align 4 +  %arrayidx2 = getelementptr inbounds i32, i32* %b, i64 %iv.0 +  %x2 = load i32, i32* %arrayidx2, align 4 +  %mul = mul i32 %x1, %x2 +  %r.1 = add i32 %mul, %r.0 +  %iv.1 = add nuw nsw i64 %iv.0, 1 +  %exitcond = icmp eq i64 %iv.1, 10 +  br i1 %exitcond, label %for.end, label %for.body + +for.end:                                          ; preds = %for.body +  ret i32 %r.1 +} diff --git a/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-geps.ll b/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-geps.ll index bc08029d4f8..723a384ea2d 100644 --- a/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-geps.ll +++ b/llvm/test/Transforms/LoopUnroll/full-unroll-heuristics-geps.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=100 -unroll-dynamic-cost-savings-discount=1000 -unroll-threshold=10 -unroll-percent-dynamic-cost-saved-threshold=40 | FileCheck %s +; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=100 -unroll-dynamic-cost-savings-discount=1000 -unroll-threshold=10 -unroll-percent-dynamic-cost-saved-threshold=60 | FileCheck %s  target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"  ; When examining gep-instructions we shouldn't consider them simplified if the | 

