diff mbox

[SMS,2/4] Move the creation of anti-dep edge

Message ID BANLkTinaAcZfqxHDToWpgxvZgo_eoQvaNQ@mail.gmail.com
State New
Headers show

Commit Message

Revital Eres May 19, 2011, 4:44 a.m. UTC
Hello,

The attached patch moves the creation of anti-dep edge from a
branch to it's def from create_ddg_dep_from_intra_loop_link () to
add_cross_iteration_register_deps  () due to the fact the edge is with
distance 1 and thus should be in the later function.
The edge was added to avoid creating reg-moves.

The patch was tested together with the rest of the patches in this series.
On ppc64-redhat-linux regtest as well as bootstrap with SMS flags
enabling SMS also on loops with stage count 1.  Regtested on SPU.
On arm-linux-gnueabi regtseted on c,c++. Bootstrap c language with SMS
flags enabling SMS also on loops with stage count 1.

OK for mainline?

Thanks,
Revital

        * ddg.c (create_ddg_dep_from_intra_loop_link): Remove the creation
        of anti-dep edge from a branch.
        (add_cross_iteration_register_deps): Create anti-dep edge from
        a branch.

Comments

Ayal Zaks May 29, 2011, 6:43 p.m. UTC | #1
Revital Eres <revital.eres@linaro.org> wrote on 19/05/2011 07:44:23 AM:

> From: Revital Eres <revital.eres@linaro.org>
> To: Ayal Zaks/Haifa/IBM@IBMIL
> Cc: gcc-patches@gcc.gnu.org, Patch Tracking <patches@linaro.org>
> Date: 19/05/2011 07:44 AM
> Subject: [PATCH, SMS 2/4] Move the creation of anti-dep edge
>
> Hello,
>
> The attached patch moves the creation of anti-dep edge from a
> branch to it's def from create_ddg_dep_from_intra_loop_link () to
> add_cross_iteration_register_deps  () due to the fact the edge is with
> distance 1 and thus should be in the later function.
> The edge was added to avoid creating reg-moves.
>
> The patch was tested together with the rest of the patches in this
series.
> On ppc64-redhat-linux regtest as well as bootstrap with SMS flags
> enabling SMS also on loops with stage count 1.  Regtested on SPU.
> On arm-linux-gnueabi regtseted on c,c++. Bootstrap c language with SMS
> flags enabling SMS also on loops with stage count 1.
>
> OK for mainline?
>

OK, this makes sense. Just to re-confirm, the exact same edges are created
in both cases, right?

>+         /* Always create the edge if the use node is a branch in
>+            order to prevent the creation of reg-moves.  */
>           if (DF_REF_ID (last_def) != DF_REF_ID (first_def)
>-              || !flag_modulo_sched_allow_regmoves)
>+              || !flag_modulo_sched_allow_regmoves
>+             || (flag_modulo_sched_allow_regmoves && JUMP_P (use_node->
insn)))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  redundant; suffices to check

+               || JUMP_P (use_node->insn))

>             create_ddg_dep_no_link (g, use_node, first_def_node,
ANTI_DEP,
>                                     REG_DEP, 1);



> Thanks,
> Revital
>
>         * ddg.c (create_ddg_dep_from_intra_loop_link): Remove the
creation
>         of anti-dep edge from a branch.
>         (add_cross_iteration_register_deps): Create anti-dep edge from
>         a branch.
>
>
> Index: ddg.c
> ===================================================================
> --- ddg.c       (revision 173785)
> +++ ddg.c       (working copy)
> @@ -197,11 +197,6 @@ create_ddg_dep_from_intra_loop_link (ddg
>          }
>      }
>
> -  /* If a true dep edge enters the branch create an anti edge in the
> -     opposite direction to prevent the creation of reg-moves.  */
> -  if ((DEP_TYPE (link) == REG_DEP_TRUE) && JUMP_P (dest_node->insn))
> -    create_ddg_dep_no_link (g, dest_node, src_node, ANTI_DEP, REG_DEP,
1);
> -
>     latency = dep_cost (link);
>     e = create_ddg_edge (src_node, dest_node, t, dt, latency, distance);
>     add_edge_to_ddg (g, e);
> @@ -306,8 +301,11 @@ add_cross_iteration_register_deps (ddg_p
>
>           gcc_assert (first_def_node);
>
> +         /* Always create the edge if the use node is a branch in
> +            order to prevent the creation of reg-moves.  */
>            if (DF_REF_ID (last_def) != DF_REF_ID (first_def)
> -              || !flag_modulo_sched_allow_regmoves)
> +              || !flag_modulo_sched_allow_regmoves
> +             || (flag_modulo_sched_allow_regmoves && JUMP_P (use_node->
insn)))
>              create_ddg_dep_no_link (g, use_node, first_def_node,
ANTI_DEP,
>                                      REG_DEP, 1);
Revital Eres May 30, 2011, 4:46 p.m. UTC | #2
Hello,

>
> OK, this makes sense. Just to re-confirm, the exact same edges are created
> in both cases, right?

No, sorry for not been more clear on this. The previous implementation
will actually create redundant anti-dep edges.  This happens when
the definition that is used in jump_insn is defined more than once
in bb.  The previous implementation created an edge between jump_insn
and it's def in this case.  This edge is redundant as anti-dep edge
between jump_insn to the first definition in the bb is also created (in
add_cross_iteration_register) and will prevent the creation of reg-moves
if -fmodulo-sched-allow-regmoves is set, which is why we created this
edge in the first place.  Here is the full explanation:

In add_cross_iteration_register an inter iteration anti-dep edges
are created between instructions that have intra true dep edge
in the opposite direction (def insn -> True dep -> use insn).
When -fmodulo-sched-allow-regmoves is set certain inter anti dep
edge are not been created.  These edges are avoided when there is
only one definition in bb for the register defined in the def insn.
The previous implementation added anti-dep edge between jump_insn and
def insn even when there is more than one definition to def insn in bb
although add_cross_iteration_register does not abort the creation of
anti-dep edges in this case (this edge will be created between jump_insn
to the first_def insn). The new patch implements a different approach
-- instead of creating additional anti-deps edge it will not abort the
creation of anti-dep edges when use insn is jump_insn.

Thanks,
Revital
diff mbox

Patch

Index: ddg.c
===================================================================
--- ddg.c       (revision 173785)
+++ ddg.c       (working copy)
@@ -197,11 +197,6 @@  create_ddg_dep_from_intra_loop_link (ddg
         }
     }

-  /* If a true dep edge enters the branch create an anti edge in the
-     opposite direction to prevent the creation of reg-moves.  */
-  if ((DEP_TYPE (link) == REG_DEP_TRUE) && JUMP_P (dest_node->insn))
-    create_ddg_dep_no_link (g, dest_node, src_node, ANTI_DEP, REG_DEP, 1);
-
    latency = dep_cost (link);
    e = create_ddg_edge (src_node, dest_node, t, dt, latency, distance);
    add_edge_to_ddg (g, e);
@@ -306,8 +301,11 @@  add_cross_iteration_register_deps (ddg_p

          gcc_assert (first_def_node);

+         /* Always create the edge if the use node is a branch in
+            order to prevent the creation of reg-moves.  */
           if (DF_REF_ID (last_def) != DF_REF_ID (first_def)
-              || !flag_modulo_sched_allow_regmoves)
+              || !flag_modulo_sched_allow_regmoves
+             || (flag_modulo_sched_allow_regmoves && JUMP_P (use_node->insn)))
             create_ddg_dep_no_link (g, use_node, first_def_node, ANTI_DEP,
                                     REG_DEP, 1);