can graal unroll loop with more blocks

Gilles Duboscq gilles.m.duboscq at oracle.com
Mon May 20 17:03:44 UTC 2019


Hi Kuai,

I don't think you need other checks but some of the unrolling code might need to be updated to deal with the new shapes.
Maybe things around `LoopTransformations#insertPrePostLoops`. Having assertions enabled should already catch some of the issues if there are any.

  Gilles

On 14/05/2019 04:55, Kuai Wei wrote:
> Hi Gilles,
> 
>     Thanks for your help. My understanding is if loop has single exit, it's an unroll candidate. I will investigate if we can apply the new rule. Is there other check we need care?
> 
> Best Regards,
> Kuai Wei
> 
>     ------------------------------------------------------------------
>     From:Gilles Duboscq <gilles.m.duboscq at oracle.com>
>     Send Time:2019年5月13日(星期一) 20:37
>     To:graal-dev <graal-dev at openjdk.java.net>
>     Subject:Re: can graal unroll loop with more blocks
> 
>     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.
> 
>        Gilles
> 
> 
>     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  LoopTransformations.java:
>      >
>      > 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