This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Force fwprop to forward propagate once used registers


Andrew Pinski wrote:
> Hi,
>   While looking into PR 36758, I noticed that fwprop does not forward
> propagate once used registers at all, leaving it up for combine and
> other passes to do it.

I like this idea, but I have a couple of nits.

First, this:

+  /* If this is a small register classes target, then don't prop if the
+     destation is a hard register.  */
+  if (SMALL_REGISTER_CLASSES && used_once
+      && DF_REF_TYPE (use) == DF_REF_REG_USE
+      && REG_P (SET_DEST (set)) && HARD_REGISTER_P (SET_DEST (set)))

seems very late, is skipped if DF_REF_TYPE (use) ==
DF_REF_REG_MEM_STORE, and does not seem related to used_once directly.
There is no need to do propagate_rtx at all in this case.  It belongs
directly in forward_propagate_into, like

  /* If fwprop would be aggressive, and this is a small register classes
     target, then don't propagate a hard register.  */
  if (SMALL_REGISTER_CLASSES
      && REG_P (SET_DEST (def_set))
      && HARD_REGISTER_P (SET_DEST (def_set)))
      && !(DF_REF_FLAGS (use) & DF_REF_IN_NOTE)   /**/
      && DF_REF_NEXT_REG (use) == NULL            /**/
      && DF_REF_PREV_REG (use) == NULL)           /**/
    return;

where any of the three conditions marked /**/ probably could be omitted
together with a change in the comment.

Second, as a further cleanup, "bool speed" and "bool used_once" in
propagate_rtx can be combined in a single "flags" parameter.  There is
already a PR_OPTIMIZE_FOR_SPEED flag, so you just have to add
PR_INTO_SOLE_USE flag or something like that and change:

  if ((flags & PR_HANDLE_MEM) && used_once)
    flags |= PR_CAN_APPEAR;
  if (speed)
    flags |= PR_OPTIMIZE_FOR_SPEED;

into just:

  if ((flags & PR_HANDLE_MEM) && (flags & PR_INTO_SOLE_USE))
    flags |= PR_CAN_APPEAR;

Thanks,

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]