[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
Thu Mar 8 21:36:19 PST 2018


reames created this revision.
reames added reviewers: hfinkel, anna, skatkov, mkazantsev.
Herald added subscribers: bollu, mcrosier.

It is common to have conditional exits within a loop which are known not to be taken on some iterations, but not necessarily all.  This patches extends our reasoning around guaranteed to execute (used when establishing whether it's safe to dereference a location from the preheader) to handle the case where an exit is known not to be taken on the first iteration and the instruction of interest *is* known to be taken on the first iteration.

This case comes up in two major ways:

1. If we have a range check which we've been unable to eliminate, we frequently know that it doesn't fail on the first iteration.
2. Pass ordering.  We may have a check which will be eliminated through some sequence of other passes, but depending on the exact pass sequence we might never actually do so or we might miss other optimizations from passes run before the check is finally eliminated.

The initial version (here) is implemented via InstSimplify.  At the moment, it catches a few cases, but misses a lot too.  I added test cases for missing cases in InstSimplify which I'll follow up on separately.  Longer term, we should probably wire SCEV through to here to get much smarted loop aware simplification of the first iteration predicate.


Repository:
  rL LLVM

https://reviews.llvm.org/D44287

Files:
  lib/Transforms/Utils/LoopUtils.cpp
  test/Transforms/LICM/hoist-mustexec.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44287.137695.patch
Type: text/x-patch
Size: 10605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180309/a3159a93/attachment.bin>


More information about the llvm-commits mailing list