diff options
| author | Philip Reames <listmail@philipreames.com> | 2019-07-31 21:15:21 +0000 | 
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2019-07-31 21:15:21 +0000 | 
| commit | f8e7b536571e7abeefcb407297df2641a5a80d35 (patch) | |
| tree | 33ca3b712149814822308137128f1e6c170b6572 /llvm/lib/Transforms | |
| parent | 04bdb25046e275613e2194eedbe39552e4638955 (diff) | |
| download | bcm5719-llvm-f8e7b536571e7abeefcb407297df2641a5a80d35.tar.gz bcm5719-llvm-f8e7b536571e7abeefcb407297df2641a5a80d35.zip | |
[IndVars, RLEV] Support rewriting exit values in loops without known exits (prep work)
This is a prepatory patch for future work on support exit value rewriting in loops with a mixture of computable and non-computable exit counts.  The intention is to be "mostly NFC" - i.e. not enable any interesting new transforms - but in practice, there are some small output changes.
The test differences are caused by cases wherewhere getSCEVAtScope can simplify a single entry phi without needing any knowledge of the loop.
llvm-svn: 367485
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 16 | 
1 files changed, 7 insertions, 9 deletions
| diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 41e22b4a212..4ccfba94e78 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -630,7 +630,8 @@ bool IndVarSimplify::rewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter) {          // and varies predictably *inside* the loop.  Evaluate the value it          // contains when the loop exits, if possible.          const SCEV *ExitValue = SE->getSCEVAtScope(Inst, L->getParentLoop()); -        if (!SE->isLoopInvariant(ExitValue, L) || +        if (isa<SCEVCouldNotCompute>(ExitValue) || +            !SE->isLoopInvariant(ExitValue, L) ||              !isSafeToExpand(ExitValue, *SE))            continue; @@ -804,7 +805,7 @@ bool IndVarSimplify::canLoopBeDeleted(    L->getExitingBlocks(ExitingBlocks);    SmallVector<BasicBlock *, 8> ExitBlocks;    L->getUniqueExitBlocks(ExitBlocks); -  if (ExitBlocks.size() > 1 || ExitingBlocks.size() > 1) +  if (ExitBlocks.size() != 1 || ExitingBlocks.size() != 1)      return false;    BasicBlock *ExitBlock = ExitBlocks[0]; @@ -2774,14 +2775,11 @@ bool IndVarSimplify::run(Loop *L) {    Rewriter.disableCanonicalMode();    Changed |= simplifyAndExtend(L, Rewriter, LI); -  // Check to see if this loop has a computable loop-invariant execution count. -  // If so, this means that we can compute the final value of any expressions +  // Check to see if we can compute the final value of any expressions    // that are recurrent in the loop, and substitute the exit values from the -  // loop into any instructions outside of the loop that use the final values of -  // the current expressions. -  // -  if (ReplaceExitValue != NeverRepl && -      !isa<SCEVCouldNotCompute>(BackedgeTakenCount)) +  // loop into any instructions outside of the loop that use the final values +  // of the current expressions. +  if (ReplaceExitValue != NeverRepl)      Changed |= rewriteLoopExitValues(L, Rewriter);    // Eliminate redundant IV cycles. | 

