diff options
author | Max Kazantsev <max.kazantsev@azul.com> | 2018-02-15 07:09:00 +0000 |
---|---|---|
committer | Max Kazantsev <max.kazantsev@azul.com> | 2018-02-15 07:09:00 +0000 |
commit | c5941d12f430ecb0efa458b3f4acd674807241ad (patch) | |
tree | 70f1659f3804614f3c3c67785269132f0ef68bfe /llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll | |
parent | 25f917341ee21d8605ddd5bb95755c49f7c4660a (diff) | |
download | bcm5719-llvm-c5941d12f430ecb0efa458b3f4acd674807241ad.tar.gz bcm5719-llvm-c5941d12f430ecb0efa458b3f4acd674807241ad.zip |
[SCEV] Favor isKnownViaSimpleReasoning over constant ranges check
There is a more powerful but still simple function `isKnownViaSimpleReasoning ` that
does constant range check and few more additional checks. We use it some places (e.g.
when proving implications) and in some other places we only check constant ranges.
Currently, indvar simplifier fails to remove the check in following loop:
int inc = ...;
for (int i = inc, j = inc - 1; i < 200; ++i, ++j)
if (i > j) { ... }
This patch replaces all usages of `isKnownPredicateViaConstantRanges` with
`isKnownViaSimpleReasoning` to have smarter proofs. In particular, it fixes the
case above.
Reviewed-By: sanjoy
Differential Revision: https://reviews.llvm.org/D43175
llvm-svn: 325214
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll')
-rw-r--r-- | llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll b/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll index 30249828107..0ce4baacedd 100644 --- a/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll +++ b/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll @@ -355,6 +355,38 @@ exit: ret void } +; check that we can prove that a recurrency is greater than another recurrency +; in the same loop, with the same step, and with smaller starting value. +define void @test12(i64* %inc_ptr) { +; CHECK-LABEL: @test12 +entry: + %inc = load i64, i64* %inc_ptr, !range !0 + %inc.minus.1 = sub i64 %inc, 1 + br label %loop + +loop: + %iv = phi i64 [ %inc, %entry ], [ %iv.next, %backedge ] + %iv.minus.1 = phi i64 [ %inc.minus.1, %entry ], [ %iv.minus.1.next, %backedge ] + %iv.next = add i64 %iv, 1 + %iv.minus.1.next = add i64 %iv.minus.1, 1 + %brcond = icmp sgt i64 %iv.next, %iv.minus.1.next + ; CHECK: br i1 true, label %if.true, label %if.false + br i1 %brcond, label %if.true, label %if.false + +if.true: + br label %backedge + +if.false: + br label %backedge + +backedge: + %loopcond = icmp slt i64 %iv, 200 + br i1 %loopcond, label %loop, label %exit + +exit: + ret void +} + !1 = !{i64 -1, i64 100} |