can graal unroll loop with more blocks

Gilles Duboscq gilles.m.duboscq at
Mon May 13 12:37:17 UTC 2019

Hi Kuai,

You can not safely change that limit there: this is not a heuristic but a necessary check because the code behind this transformation will produce incorrect results with more blocks.

It would be not be very hard to change this limit to be about the loop having a single loop exit. But with multiple loop exits it would be a much larger change.


On 13/05/2019 13:57, Kuai Wei wrote:
> Hello,
>    Recently I checked loop unroll optimization in Graal compiler. I found it has a strict check to limit unroll loop with 1 or 2 blocks.
> In
> public static boolean isUnrollableLoop(LoopEx loop) {
>    ...
>    if (loopBegin.isMainLoop() || loopBegin.isSimpleLoop()) {
>              // Flow-less loops to partial unroll for now. 3 blocks corresponds to an if that either
>              // exits or continues the loop. There might be fixed and floating work within the loop
>              // as well.
>              if (loop.loop().getBlocks().size() < 3) {
>                  return true;
>              }
>              condition.getDebug().log(DebugContext.VERBOSE_LEVEL, "isUnrollableLoop %s too large to unroll %s ", loopBegin, loop.loop().getBlocks().size());
>     }
> I'm wondering why Graal has this limit. It will block many loops to be unrolled. Could we increase the block size here?
> Thanks,
> Kuai Wei

More information about the graal-dev mailing list