[llvm] r308847 - [SCEV] Limit max size of AddRecExpr during evolving

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 10:16:07 PDT 2017


Merged in r310629.

Thanks,
Hans

On Wed, Aug 9, 2017 at 9:05 PM, Maxim Kazantsev <max.kazantsev at azul.com> wrote:
> I think yes, it should.
>
> -- Max
>
> -----Original Message-----
> From: Sanjoy Das [mailto:sanjoy at playingwithpointers.com]
> Sent: Thursday, August 10, 2017 6:50 AM
> To: Hans Wennborg <hans at chromium.org>
> Cc: Maxim Kazantsev <max.kazantsev at azul.com>; llvm-commits <llvm-commits at lists.llvm.org>
> Subject: Re: [llvm] r308847 - [SCEV] Limit max size of AddRecExpr during evolving
>
> On Wed, Aug 9, 2017 at 4:48 PM, Hans Wennborg <hans at chromium.org> wrote:
>> Ping?
>>
>> On Wed, Jul 26, 2017 at 9:57 AM, Hans Wennborg <hans at chromium.org> wrote:
>>> Should this be merged to 5.0?
>
> SGTM.  Max?
>
>>>
>>> On Sun, Jul 23, 2017 at 8:40 AM, Max Kazantsev via llvm-commits
>>> <llvm-commits at lists.llvm.org> wrote:
>>>> Author: mkazantsev
>>>> Date: Sun Jul 23 08:40:19 2017
>>>> New Revision: 308847
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=308847&view=rev
>>>> Log:
>>>> [SCEV] Limit max size of AddRecExpr during evolving
>>>>
>>>> When SCEV calculates product of two SCEVAddRecs from the same loop,
>>>> it tries to combine them into one big AddRecExpr. If the sizes of
>>>> the initial SCEVs were `S1` and `S2`, the size of their product is
>>>> `S1 + S2 - 1`, and every operand of the resulting SCEV is combined
>>>> from operands of initial SCEV and has much higher complexity than they have.
>>>>
>>>> As result, if we try to calculate something like:
>>>>   %x1 = {a,+,b}
>>>>   %x2 = mul i32 %x1, %x1
>>>>   %x3 = mul i32 %x2, %x1
>>>>   %x4 = mul i32 %x3, %x2
>>>>   ...
>>>> The size of such SCEVs grows as `2^N`, and the arguments become more
>>>> and more complex as we go forth. This leads to long compilation and
>>>> huge memory consumption.
>>>>
>>>> This patch sets a limit after which we don't try to combine two
>>>> `SCEVAddRecExpr`s into one. By default, max allowed size of the
>>>> resulting AddRecExpr is set to 16.
>>>>
>>>> Differential Revision: https://reviews.llvm.org/D35664
>>>>
>>>> Added:
>>>>     llvm/trunk/test/Analysis/ScalarEvolution/max-addrec-size.ll
>>>> Modified:
>>>>     llvm/trunk/lib/Analysis/ScalarEvolution.cpp


More information about the llvm-commits mailing list