> On Thu, Aug 20, 2020 at 6:35 AM guojiufu via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > Hi, > > > > When unroll loops, if there are calls inside the loop, those calls > > may raise negative impacts for unrolling. This patch adds a param > > param_max_unrolled_calls, and checks if the number of calls inside > > the loop bigger than this param, loop is prevent from unrolling. > > > > 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. > > > > Bootstrap and regtest pass on powerpc64le. Is this ok for trunk? > > 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.
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. Honza