can graal unroll loop with more blocks

Kuai Wei kuaiwei.kw at alibaba-inc.com
Mon May 13 11:57:56 UTC 2019


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