On Sat, Mar 28, 2020 at 4:19 AM xiezhiheng <xiezhih...@huawei.com> wrote:
>
> Hi,
>   I find there exists some restricts in function fwprop preventing it to 
> forward propagate addresses into loops.
> /* Go through all the uses.  df_uses_create will create new ones at the
>    end, and we'll go through them as well.
>
>    Do not forward propagate addresses into loops until after unrolling.
>    CSE did so because it was able to fix its own mess, but we are not.  */
> for (i = 0; i < DF_USES_TABLE_SIZE (); i++)
>   {
>     if (!propagations_left)
>       break;
>
>     df_ref use = DF_USES_GET (i);
>     if (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)
>           forward_propagate_into (use, fwprop_addr_p);
>
>         else if (fwprop_addr_p)
>           forward_propagate_into (use, false);
>       }
>   }
>
>   And I have two questions.
>   1) What are the reasons or background for not forward propagating addresses 
> into loops ?
>   2) Can we still forward propagate addresses if the def and use are in the 
> same loop ?
>   I mean something like:

The condiition indeed looks odd, the canonical way would be to check

  !flow_loop_nested_p (DF_REF_BB (def)->loop_father, DF_REF_BB
(use)->loop_father)

which would allow propagating addresses defined in loops outside as well.
And loop_father should never be NULL I think.

> diff -Nurp a/gcc/fwprop.c b/gcc/fwprop.c
> --- a/gcc/fwprop.c      2020-03-27 03:17:50.704000000 -0400
> +++ b/gcc/fwprop.c      2020-03-27 04:58:35.148000000 -0400
> @@ -1573,10 +1573,12 @@ 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))
>             forward_propagate_into (use, fwprop_addr_p);
>
>           else if (fwprop_addr_p)
>
> I would be grateful if anyone could help.
>
> Best regards

Reply via email to