This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: CFG transformation of loops with continue statement inside the loops.
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Ajit Kumar Agarwal <ajit dot kumar dot agarwal at xilinx dot com>
- Cc: "law at redhat dot com" <law at redhat dot com>, Jan Hubicka <hubicka at ucw dot cz>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Vinod Kathail <vinodk at xilinx dot com>, Shail Aditya Gupta <shailadi at xilinx dot com>, Vidhumouli Hunsigida <vidhum at xilinx dot com>, Nagaraju Mekala <nmekala at xilinx dot com>
- Date: Thu, 9 Jul 2015 10:14:43 +0200
- Subject: Re: CFG transformation of loops with continue statement inside the loops.
- Authentication-results: sourceware.org; auth=none
- References: <37378DC5BCD0EE48BA4B082E0B55DFAA41F42D04 at XAP-PVEXMBX02 dot xlnx dot xilinx dot com>
On Wed, Jul 8, 2015 at 4:46 PM, Ajit Kumar Agarwal
<ajit.kumar.agarwal@xilinx.com> wrote:
> All:
>
> While/For ( condition1)
> {
> Some code here.
> If(condition2 )
> continue;
> Some code here.
> }
>
> Fig(1)
>
> For the above loop in Fig(1) there will be two backedges and multiple latches. The below code can be transformed to the below in order to
> have a single backedge.
>
> While/For (condition1)
> {
> Some code here.
> If( condition2)
> Goto latch;
> Some code here.
>
> Latch:
> }
>
> Fig(2).
>
> With the transformation shown in Fig(2) the presence of GoTo inside loops affect and disables many optimizations. To enable
> the loops in Fig(1) can also be transformed to multiple loops with each backedge that will make the affected optimizations enabled
> and the transformed Multiple loops will enable many optimizations that are disabled with the presence of GoTo in Fig(2) and multiple
> latches given in Fig(1).
This is what GCC performs when doing loop_optimizer_init without
LOOPS_MAY_HAVE_MULTIPLE_LATCHES, it will
disambiguate the loop into a nested loop. We don't have a way to
force a single latch with the goto idea (which might
be useful in some cases as well, for example if the result can be
trivially if-converted).
Richard.
> Thoughts?
>
> Thanks & Regards
> Ajit
>