[PATCH] D69830: [LoopPred/WC] Use a dominating widenable condition to remove analyze loop exits

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 15:39:07 PST 2019


reames created this revision.
reames added reviewers: apilipenko, skatkov, fedor.sergeev.
Herald added subscribers: bollu, hiraditya, mcrosier.
Herald added a project: LLVM.

This implements a version of the predicateLoopExits transform from IndVarSimplify extended to exploit widenable conditions - and thus be much wider in scope of legality.  The code structure ends up being almost entirely different, so I chose to duplicate this into the LoopPredication pass instead of trying to reuse the code in the IndVars.

The core notions of the transform are as follows:

1. If we have a widenable condition which controls entry into the loop, we're allowed to widen it arbitrarily.  Given that, it's simply a *profitability* question as to what conditions to fold into the widenable branch.
2. To avoid pass ordering issues, we want to avoid widening cases that would otherwise be dischargeable.  Or, widen in a form which can still be discharged.  Thus, we phrase the transform as selecting one analyzeable exit from the set of analyzeable exits to keep.  This avoids creating pass ordering complexities.
3. Since none of the above proves that we actually exit through our analyzeable exits - we might exit through something else entirely - we limit ourselves to cases where a) the latch is analyzeable and b) the latch is predicted taken, and c) the exit being removed is statically cold.


Repository:
  rL LLVM

https://reviews.llvm.org/D69830

Files:
  llvm/lib/Transforms/Scalar/LoopPredication.cpp
  llvm/test/Transforms/LoopPredication/predicate-exits.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69830.227793.patch
Type: text/x-patch
Size: 44430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191104/bbfc9f86/attachment.bin>


More information about the llvm-commits mailing list