diff options
| author | Max Kazantsev <max.kazantsev@azul.com> | 2017-10-25 11:07:43 +0000 |
|---|---|---|
| committer | Max Kazantsev <max.kazantsev@azul.com> | 2017-10-25 11:07:43 +0000 |
| commit | b6d40067af8ef18117d94c889e01824376a441c3 (patch) | |
| tree | f45124b4df384bb869847e0abf551f2b1f572601 /llvm/test/Transforms/IndVarSimplify | |
| parent | 0c7cd071f7916a4f9a0bdc70a58b8477c3700e38 (diff) | |
| download | bcm5719-llvm-b6d40067af8ef18117d94c889e01824376a441c3.tar.gz bcm5719-llvm-b6d40067af8ef18117d94c889e01824376a441c3.zip | |
[SCEV] Enhance SCEVFindUnsafe for division
This patch allows SCEVFindUnsafe algorithm to tread division by any non-positive
value as safe. Previously, it could only recognize non-zero constants.
Differential Revision: https://reviews.llvm.org/D39228
llvm-svn: 316568
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify')
| -rw-r--r-- | llvm/test/Transforms/IndVarSimplify/udiv.ll | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/udiv.ll b/llvm/test/Transforms/IndVarSimplify/udiv.ll index b3f2c2a6a66..0f9a54e8c4f 100644 --- a/llvm/test/Transforms/IndVarSimplify/udiv.ll +++ b/llvm/test/Transforms/IndVarSimplify/udiv.ll @@ -130,11 +130,11 @@ declare i32 @printf(i8* nocapture, ...) nounwind ; IndVars doesn't emit a udiv in for.body.preheader since SCEVExpander::expand will ; find out there's already a udiv in the original code. -; CHECK-LABEL: @foo( +; CHECK-LABEL: @foo_01( ; CHECK: for.body.preheader: ; CHECK-NOT: udiv -define void @foo(double* %p, i64 %n) nounwind { +define void @foo_01(double* %p, i64 %n) nounwind { entry: %div0 = udiv i64 %n, 7 ; <i64> [#uses=1] %div1 = add i64 %div0, 1 @@ -160,3 +160,39 @@ for.end.loopexit: ; preds = %for.body for.end: ; preds = %for.end.loopexit, %entry ret void } + +; Same as foo_01, but we divide by non-constant value. + +; CHECK-LABEL: @foo_02( +; CHECK: for.body.preheader: +; CHECK-NOT: udiv + +define void @foo_02(double* %p, i64 %n, i64* %lp) nounwind { +entry: + %denom = load i64, i64* %lp, align 4, !range !0 + %div0 = udiv i64 %n, %denom ; <i64> [#uses=1] + %div1 = add i64 %div0, 1 + %cmp2 = icmp ult i64 0, %div1 ; <i1> [#uses=1] + br i1 %cmp2, label %for.body.preheader, label %for.end + +for.body.preheader: ; preds = %entry + br label %for.body + +for.body: ; preds = %for.body.preheader, %for.body + %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ] ; <i64> [#uses=2] + %arrayidx = getelementptr inbounds double, double* %p, i64 %i.03 ; <double*> [#uses=1] + store double 0.000000e+00, double* %arrayidx + %inc = add i64 %i.03, 1 ; <i64> [#uses=2] + %divx = udiv i64 %n, %denom ; <i64> [#uses=1] + %div = add i64 %divx, 1 + %cmp = icmp ult i64 %inc, %div ; <i1> [#uses=1] + br i1 %cmp, label %for.body, label %for.end.loopexit + +for.end.loopexit: ; preds = %for.body + br label %for.end + +for.end: ; preds = %for.end.loopexit, %entry + ret void +} + +!0 = !{i64 1, i64 10} |

