[PATCH] D67359: [IVUser] Limit the iterations to check whether a loop has dedicated exits for extreme large case

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 10:27:14 PDT 2019


wmi added a comment.

In D67359#1664243 <https://reviews.llvm.org/D67359#1664243>, @skatkov wrote:

> In D67359#1664242 <https://reviews.llvm.org/D67359#1664242>, @wmi wrote:
>
> > In D67359#1664241 <https://reviews.llvm.org/D67359#1664241>, @skatkov wrote:
> >
> > > I wonder whether the problem is in this function or in analysis itself?
> > >  If it is a problem of analysis it is better to restrict it but not an utility function.
> >
> >
> > I feel the problem is in the utility function. Currently the problem is exposed in IVUser pass but the same can happen anywhere else if only the function is called for a huge loop with many exits and with each exit having many predecessors.
>
>
> Can you do some measurements to ensure that the issue is really in this utility function but not in the user of it?


I did that. For the huge loop, every call of hasDedicatedExits took about 3~5 seconds. hasDedicatedExits is called by isSimplifiedLoopNest which is used by IVUser pass. Indeed there is another problem that IVUser pass calls isSimplifiedLoopNest for the same loop multiple times (~200). However, IVUser is a loop analysis pass, and isSimplifiedLoopNest can be called for a loop different from the current loop analyzed. So isSimplifiedLoopNest is called for the same huge loop many times for many different invocations of IVUser pass analyzing different loops, and the cache mechanism local to IVUser doesn't work for it.

I understand it is possible to mitigate the problem in IVUser (I don't know how to do that yet. The original commit to add isSimplifiedLoopNest was r152892 in 2012 and the original bug was in rdar://problem/11049788 which I cannot read) but it seems also reasonable to put a limit in hasDedicatedExits -- For my case, the loop with 4000 exits + each exit has 1000 predecessors took 3~5 seconds for each call of hasDedicatedExits. It is already noticeable to compiler users. If the loop is larger, it will take more time even if hasDedicatedExits is called only once for it. I think it is better to put a limit for such high cost function and that is independent to improve the cache or algorithm in IVUser.

> At the same time it makes sense to update function description to specify that with your change the function can conservatively returns no if it could not get the precise answer.

That makes sense. I will do that.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67359/new/

https://reviews.llvm.org/D67359





More information about the llvm-commits mailing list