[PATCH] Check calls before loop unrolling

Jiufu Guo guojiufu@linux.ibm.com
Tue Aug 25 02:26:14 GMT 2020

On 2020-08-24 19:16, Jan Hubicka wrote:
>> On Thu, Aug 20, 2020 at 6:35 AM guojiufu via Gcc-patches
>> <gcc-patches@gcc.gnu.org> wrote:
>> >
>> > Hi,
>> >
>> > This patch is checking the _average_ number of calls which is the
>> > summary of call numbers multiply the possibility of the call maybe
>> > executed.  The _average_ number could be a fraction, to keep the
>> > precision, the param is the threshold number multiply 10000.
>> >
>> Can you try mimicking what try_unroll_loop_completely on GIMPLE does
>> instead?  IIRC the main motivation to not unroll calls is the spilling 
>> code
>> around it which we cannot estimate very well.  And that spilling 
>> happens
>> irrespective of whether the call is in a hot or cold path so I'm not 
>> sure
>> it makes sense to use the "average" number of calls here.

In try_unroll_loop_completely, it is checking the calls in the hot path:
num_non_pure_calls_on_hot_path), and avoid unrolling if there is.
This is one reason for here to use "average".
> As long as I remember, we excluded calls simply becuase it is/was an
> expensive intruction so it was an indication that the loop overhead is
> small compared to the overhead of loop body.

Thanks, Honza and Richard!
> Honza

More information about the Gcc-patches mailing list