[PATCH, stage1][PR65443] Add transform_to_exit_first_loop_alt

Tom de Vries Tom_deVries@mentor.com
Fri Mar 27 14:10:00 GMT 2015


Hi,

this patch fixes PR65443, a todo in the parloops pass for function 
transform_to_exit_first_loop:
...
    TODO: the common case is that latch of the loop is empty and immediately
    follows the loop exit.  In this case, it would be better not to copy the
    body of the loop, but only move the entry of the loop directly before the
    exit check and increase the number of iterations of the loop by one.
    This may need some additional preconditioning in case NIT = ~0.
...

The current implementation of transform_to_exit_first_loop transforms the loop 
by moving and duplicating the loop body. This patch transforms the loop into the 
same normal form, but without the duplication, if that's possible (determined by 
try_transform_to_exit_first_loop_alt).

The actual transformation, done by transform_to_exit_first_loop_alt transforms 
this loop:
...
      bb preheader:
      ...
      goto <bb header>

      <bb header>:
      ...
      if (ivtmp < n)
        goto <bb latch>;
      else
        goto <bb exit>;

      <bb latch>:
      ivtmp = ivtmp + inc;
      goto <bb header>
...

into this one:
...
      bb preheader:
      ...
      goto <bb newheader>

      <bb header>:
      ...
      goto <bb latch>;

      <bb newheader>:
      if (ivtmp < n + 1)
        goto <bb header>;
      else
        goto <bb exit>;

      <bb latch>:
      ivtmp = ivtmp + inc;
      goto <bb newheader>
...

Bootstrapped and reg-tested on x86_64.

OK for stage1 trunk?

Thanks,
- Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-transform_to_exit_first_loop_alt.patch
Type: text/x-patch
Size: 18627 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150327/f1080e67/attachment.bin>


More information about the Gcc-patches mailing list