On Thu, 2020-04-02 at 06:35 +0000, xiezhiheng wrote: > 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: > 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) > > Any suggestions? ISTM this is really either a gimple issue or a gimple->rtl expansion issue. Yea, we *could* fix this via propagation, but ISTM it's better to generate reasonable code from the start rather than try to optimize it later.
jeff