[PATCH] D60093: [LoopPredication] Allow predication of loop invariant computations

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 13:43:50 PDT 2019


reames updated this revision to Diff 195243.
reames added a comment.

Update after rebasing over previous changes.  This is a fairly major rework though, so please review from scratch.

Key thing is that I stumbled across a bug in the previous implementation.  I've committed the test to highlight it as neg_invariant_latch_limit.  The problem is that SCEV turns out not to be correctly handling dominance within a single block within isSafeToSpeculateAt.   The fix for that is included, along with just enough special casing to keep all of the existing tests passing.

Secondly, I realized that we were mixing two different concepts and that's what made the bug possible.  Given that, I restructured the change to check invariance separately from insertion safety.  This relies on the previous patch which made it clear that insertion at the guard is always valid, and that hoisting out of the loop is purely an optimization.  Interestingly, splitting in this manner actually makes the transform *more* powerful, not less.  See the (correct) diffs around udiv handling.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60093/new/

https://reviews.llvm.org/D60093

Files:
  lib/Analysis/ScalarEvolutionExpander.cpp
  lib/Transforms/Scalar/LoopPredication.cpp
  test/Transforms/LoopPredication/basic.ll
  test/Transforms/LoopPredication/basic_widenable_branch_guards.ll
  test/Transforms/LoopPredication/invariant_load.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60093.195243.patch
Type: text/x-patch
Size: 13394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190415/f1e0b570/attachment.bin>


More information about the llvm-commits mailing list