Philip Reames via llvm-dev
2021-Jul-16 14:52 UTC
[llvm-dev] Question about Unrolling Loop with Multiple Exits
A) Are you measuring on tip of tree? There were changes for multiple exit unrolling which landed very recently. B) One of your exits does not dominate your latch. Those are generally hard. C) This example does not seem to require gotos. I strongly suggest reducing your test cases if you want more informed commentary. Philip On 7/16/21 7:42 AM, Jingu Kang via llvm-dev wrote:> > 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 > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210716/abcd8085/attachment.html>
Jingu Kang via llvm-dev
2021-Jul-16 16:29 UTC
[llvm-dev] Question about Unrolling Loop with Multiple Exits
Hi Philip, Thanks for your kind reply.> A) Are you measuring on tip of tree?� There were changes for multiple exit unrolling which landed very recently.Yep, I am investigating benchmarks with llvm tip and I can see the llvm fails to unroll some loops with multiple exits.> B) One of your exits does not dominate your latch.� Those are generally hard > C) This example does not seem to require gotos.� I strongly suggest reducing your test cases if you want more informed commentary.�I am looking at perlbench recently and it has `goto` statements inside loop. The example is a reduced case. When I look at the gcc's output of the example, it looks like gcc unrolls only the below `if` statement block... if (*s++ != '\n') continue; Thanks JinGu Kang From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Philip Reames via llvm-dev Sent: 16 July 2021 15:52 To: Jingu Kang <Jingu.Kang at arm.com>; llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Question about Unrolling Loop with Multiple Exits A) Are you measuring on tip of tree?� There were changes for multiple exit unrolling which landed very recently. B) One of your exits does not dominate your latch.� Those are generally hard.� C) This example does not seem to require gotos.� I strongly suggest reducing your test cases if you want more informed commentary.� Philip On 7/16/21 7:42 AM, Jingu Kang via llvm-dev wrote: 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 � � � � � � _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210716/e2f0c72a/attachment.html>