[PATCH] D112060: [NARY-REASSOCIATE] Fix infinite recursion optimizing min\max

Evgeniy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 19 03:15:33 PDT 2021


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

To guarantee convergence of the algorithm each optimization step should decrease number of instructions when IR is modified. This property is not held in this test case. The problem is that SCEV Expander may do "unexpected" reassociation what results in creation of new min/max chains and introduction of extra instructions. As a result on each step we indefinitely optimize back and forth.

The solution is to restrict SCEV Expander to perform uncontrolled reassociations by means of "Unknown" expressions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112060

Files:
  llvm/lib/Transforms/Scalar/NaryReassociate.cpp
  llvm/test/Transforms/NaryReassociate/nary-req.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112060.380630.patch
Type: text/x-patch
Size: 4730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211019/131bc81b/attachment.bin>


More information about the llvm-commits mailing list