[PATCH] D110620: [WIP][SCEV] Infer ranges for SCC consisting of cycled Phis

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 04:52:54 PDT 2021


mkazantsev created this revision.
Herald added subscribers: javed.absar, hiraditya.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Our current strategy of computing ranges of SCEVUnknown Phis was to simply
compute the union of ranges of all its inputs. In order to avoid infinite recursion,
we mark Phis as pending and conservatively return full set for them. As result,
even simplest patterns of cycled phis always have a range of full set.

This patch makes this logic a bit smarter. We basically do the same, but instead
of taking inputs of single Phi we find its strongly connected component (SCC)
and compute the union of all inputs that come into this SCC from outside.

Processing entire SCC together has one more advantage: we can set range for all
of them at once, because the only thing that happens to them is the same value is
being passed between those Phis. So, despite we spend more time analyzing a
single Phi, overall we may save time by not processing other SCC members, so
amortized compile time spent should be approximately the same.


https://reviews.llvm.org/D110620

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/cycled_phis.ll
  llvm/test/Analysis/ScalarEvolution/unknown_phis.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110620.375529.patch
Type: text/x-patch
Size: 8064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/cbd8ab7f/attachment-0001.bin>


More information about the llvm-commits mailing list