[PATCH] D69695: [LoopPred] Fix two subtle issues found by inspection

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 17:21:58 PDT 2019


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

This patches fixes two issues noticed by inspection when going to enable the loop predication code in IndVarSimplify.  Arguably, these could be split.  If reviewers want me to do so, I'm happy to do so.

Issue 1 - Both the LoopPredication transform, and the already on by default optimizeLoopExits transform, modify the exit count of the exits they modify.  (either to 0 or Infinity)  Looking at the code more closely, this was not reflected into SCEV and we were instead running later transforms with incorrect SCEVs.  Fixing this requires forgetting the loop, weakening a too strong assert, and updating SCEV to not pessimize results when a loop is provable untaken.  I haven't been able to find a test case to demonstrate the miscompile.

Issue 2 - For modules without a data layout, we can end up with unsized pointer typed exit counts.  Just bail out of this case.

I think these are the last two issues which need addressed before we enable this by default.  The code has already survived a decent amount of fuzzing without revealing either of the above.


Repository:
  rL LLVM

https://reviews.llvm.org/D69695

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69695.227380.patch
Type: text/x-patch
Size: 4157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191101/9265e731/attachment.bin>


More information about the llvm-commits mailing list