[PATCH] D44287: [LICM] Ignore exits provably not taken on first iteration when computing must execute
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 9 15:22:48 PST 2018
reames added inline comments.
================
Comment at: lib/Transforms/Utils/LoopUtils.cpp:1535
+ // todo: this would be a lot more powerful if we used scev, but all the
+ // plumbing is currently missing
+ auto *ICI = dyn_cast<ICmpInst>(BI->getCondition());
----------------
anna wrote:
> I think we do have SCEV logic to handle this case, but it maybe much weaker than InstSimplify. What we need is something along these lines but `getMin` instead of `getExact` for a given exiting block.
> ```
> /// Return the number of times this loop exit may fall through to the back
> /// edge, or SCEVCouldNotCompute. The loop is guaranteed not to exit via
> /// this block before this number of iterations, but may exit via another
> /// block.
> const SCEV *getExact(BasicBlock *ExitingBlock, ScalarEvolution *SE) const;
> ```
> For every ExitBlock that `Inst` does not dominate, get the exiting block which is its single Predecessor (bail out if more than one). Then we just call this SCEV routine. Right now, since it only returns the "exact" count, we maybe usually returning `CouldNotCompute`.
>
Seemly like my comment was unclear. I agree SCEV has lots of useful handling here. I don't think the conservatism you sketch is a problem in practice. The main issue is we simply don't pass a pointer to SCEV in from LICM at the moment. :)
Repository:
rL LLVM
https://reviews.llvm.org/D44287
More information about the llvm-commits
mailing list