[PATCH] D76273: [NFCI][SCEV] Avoid recursion in SCEVExpander::isHighCostExpansion*()

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 17 03:00:46 PDT 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: mkazantsev, reames, wmi, ekatz.
lebedev.ri added a project: LLVM.
Herald added subscribers: javed.absar, hiraditya.
lebedev.ri retitled this revision from "[SCEV] Avoid recursion in SCEVExpander::isHighCostExpansion*()" to "[NFCI][SCEV] Avoid recursion in SCEVExpander::isHighCostExpansion*()".

As noted in PR45201 <https://bugs.llvm.org/show_bug.cgi?id=45201>,
PR10090 <https://bugs.llvm.org/show_bug.cgi?id=10090> SCEV doesn't always avoid
recursive algorithms, and that causes issues with large expression depths and/or smaller stack sizes.

In `SCEVExpander::isHighCostExpansion*()` case, the refactoring to avoid recursion
is rather idiomatic. We simply need to place the root expr into a vector,
and iterate over vector elements accounting for the cost of each one,
and add new exprs at the end of the vector, thus achieving FIFO breadth-first traversal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76273

Files:
  llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
  llvm/lib/Analysis/ScalarEvolutionExpander.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76273.250709.patch
Type: text/x-patch
Size: 6568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200317/a5536a1e/attachment.bin>


More information about the llvm-commits mailing list