[PATCH] D103991: [SCEV] Extend mustprogress reasoning to ne exit tests

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 9 14:48:44 PDT 2021


reames created this revision.
reames added reviewers: nikic, mkazantsev.
Herald added subscribers: bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

The motivation here is simple loops with unsigned induction variables w/non-one steps and inequality tests. A toy example would be:
for (unsigned i = 0; i != N; i += 2) { body; }

If body contains no side effects, and this is a mustprogress function, we can assume that this must be a finite loop and thus that the exit count is N/2.

This builds on the logic from 38540d71 <https://reviews.llvm.org/rG38540d71c74c2f63a77993e7bfb6e52e4b0da0fc>, and is more fully explained there.  Note that we canonicalize to NE tests in LFTR, so after the previous change we'd compute an exit count, perform LFTR, and then "forget" what the exit count was again.

I plan on extending this to GT tests in a future change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103991

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/ne-overflow.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103991.350999.patch
Type: text/x-patch
Size: 11883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210609/37dcaa8a/attachment.bin>


More information about the llvm-commits mailing list