[PR94442,AArch64] Redundant ldp/stp instructions emitted at -O3

Message ID DB39BCECAC4E7F4FB40D5AFFB835A5651ECCB95C@dggemm501-mbs.china.huawei.com
State New
Headers show
Series
  • [PR94442,AArch64] Redundant ldp/stp instructions emitted at -O3
Related show

Commit Message

xiezhiheng April 2, 2020, 6:35 a.m.
Hi,
  I've created a bug for this issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94442

  And I'm going to solve this problem by propagating def's insn to its use
  when they are at the same loop in fwprop pass.
  I mean something like:

Any suggestions?

Best regards
Xie Zhiheng

Patch

diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 705d2885aae..0edbbc65047 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -416,7 +416,7 @@  should_replace_address (rtx old_rtx, rtx new_rtx, machine_mode mode,
     gain = (set_src_cost (new_rtx, VOIDmode, speed)
            - set_src_cost (old_rtx, VOIDmode, speed));

-  return (gain > 0);
+  return (gain >= 0);
 }


@@ -1573,10 +1573,14 @@  fwprop (bool fwprop_addr_p)
       df_ref use = DF_USES_GET (i);
       if (use)
        {
+         df_ref def = get_def_for_use (use);
          if (DF_REF_TYPE (use) == DF_REF_REG_USE
              || DF_REF_BB (use)->loop_father == NULL
              /* The outer most loop is not really a loop.  */
-             || loop_outer (DF_REF_BB (use)->loop_father) == NULL)
+             || loop_outer (DF_REF_BB (use)->loop_father) == NULL
+             || (def && (DF_REF_BB (def)->loop_father == DF_REF_BB (use)->loop_father
+                         || flow_loop_nested_p (DF_REF_BB(use)->loop_father,
+                                                DF_REF_BB(def)->loop_father))))
            forward_propagate_into (use, fwprop_addr_p);

          else if (fwprop_addr_p)