OSDN Git Service

[SCEV] Fix isKnownPredicate
authorSerguei Katkov <serguei.katkov@azul.com>
Tue, 13 Mar 2018 06:10:27 +0000 (06:10 +0000)
committerSerguei Katkov <serguei.katkov@azul.com>
Tue, 13 Mar 2018 06:10:27 +0000 (06:10 +0000)
commit579aaf149ed60133d7be8ef3d654378af61bc764
tree641fe5c6286f982dc4f301d37dcc30aa39508204
parent97fa4365e0a32b4e93026cf4086f8f050e0399b5
[SCEV] Fix isKnownPredicate

IsKnownPredicate is updated to implement the following algorithm
proposed by @sanjoy and @mkazantsev :
isKnownPredicate(Pred, LHS, RHS) {
  Collect set S all loops on which either LHS or RHS depend.
  If S is non-empty
    a. Let PD be the element of S which is dominated by all other elements of S
    b. Let E(LHS) be value of LHS on entry of PD.
       To get E(LHS), we should just take LHS and replace all AddRecs that
       are attached to PD on with their entry values.
       Define E(RHS) in the same way.
    c. Let B(LHS) be value of L on backedge of PD.
       To get B(LHS), we should just take LHS and replace all AddRecs that
       are attached to PD on with their backedge values.
       Define B(RHS) in the same way.
    d. Note that E(LHS) and E(RHS) are automatically available on entry of PD,
       so we can assert on that.
    e. Return true if isLoopEntryGuardedByCond(Pred, E(LHS), E(RHS)) &&
                      isLoopBackedgeGuardedByCond(Pred, B(LHS), B(RHS))
Return true if Pred, L, R is known from ranges, splitting etc.
}
This is follow-up for https://reviews.llvm.org/D42417.

Reviewers: sanjoy, mkazantsev, reames
Reviewed By: sanjoy, mkazantsev
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D43507

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327362 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
test/Transforms/IndVarSimplify/inner-loop-by-latch-cond.ll [new file with mode: 0644]