This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CFG transformation of loops with continue statement inside the loops.


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
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]