[llvm-dev] Question about Unrolling Loop with Multiple Exits

Jingu Kang via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 16 07:42:22 PDT 2021


Hi All,

While I am investigating benchmarks, I have found loops which llvm fails to unroll because the loops have multiple exits.
For example,

char *foo(void);
int boo(char *s);

int test(char *s, char *end, char *check1, char *check2) {
  while (s <= end) {
    if (*s++ != '\n')
      continue;
    if (check1 || check2) {
      s = foo();
      if (!s)
        goto ret1;
    }
    if (boo(s))
      goto ret0;
  }
  goto ret1;

ret0:
  return 0;
ret1:
  return 1;
}

Above code causes below messages from LoopUnroll pass.

Bailout for multi-exit handling when latch exit has >1 predecessor.
Multiple exit/exiting blocks in loop and multi-exit unrolling not enabled!

I can see the option `unroll-runtime-multi-exit` and comments about it. I wonder there are already reviews for the work on phabriactor or some people are working on it.
If someone knows information about it, please share it.

Thanks
JinGu Kang






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210716/479055bd/attachment-0001.html>


More information about the llvm-dev mailing list