[PATCH] D114650: [SCEV] Construct SCEV iteratively (WIP).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 26 10:09:16 PST 2021


fhahn created this revision.
fhahn added reviewers: nikic, reames, mkazantsev, lebedev.ri, efriedma.
Herald added subscribers: javed.absar, hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

WIP WIP WIP

This patch is an attempt to build SCEVs iteratively rather than
recursively. It resolves stack overflow issues when trying to construct
SCEVs for certain inputs, e.g. PR45201.

The basic approach is to to use a worklist to queue operands of V which
need to be created before V. To do so, the current patch adds a
getOperandsToCreate function which collects the operands SCEV
construction depends on for a given value. This is a slight duplication
with createSCEV.

At the moment, there are still a few things that are not handled, e.g.
non-simple AddRec phis, but there are only very few test failures
already. My plan is to first get down to zero test failures and move to
perf tuning from there. Any high-level thoughts and suggestions would be
very welcome!

Compile-time impact at the moment is a ~0.28% geomean regression on the
http://llvm-compile-time-tracker.com/compare.php?from=1702a2305b775c04dfeab4640d9fa2a2b193c6b3&to=d09b875c0eb2cac4bf33af8349ecd8c54da70e11&stat=instructions

Note those numbers are D114260 <https://reviews.llvm.org/D114260>/D114633 <https://reviews.llvm.org/D114633>.

One notable change/complication is that getBackedgeTakenInfo may
remove/forget expressions while iteratively constructing SCEVs. So in
some cases, a SCEV we constructed earlier will get removed before it is
used be one of the next iterations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114650

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114650.390092.patch
Type: text/x-patch
Size: 28508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211126/ecf5d1f3/attachment-0001.bin>


More information about the llvm-commits mailing list