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]

[Committed] Avoid unnecessary pseudos in emit_group_store


Whilst investigating PR target/17959 which is a poor code generation
issue on powerpc with -mpowerpc64, I noticed that RTL expansion was
generating a large number of unnecessary register-to-register moves.
These are all cleaned up by later RTL passes, but waste memory and
needlessly slow down the compiler.  The source was emit_group_store
that contains the comment "Copy the (probable) hard regs into pseudos".
It turns out that this code to avoid potential problems with hard regs
wasn't considering the case that the source was already a suitable
pseudo (non-hard) register, a common case for GCC with some ABIs.

The patch below cleans up this code.  It's convenient to get this
independent tweak into the tree, before posting other changes
to emit_group_store.


The following (nearly obvious) clean-up patch has been tested on
powerpc-unknown-linux-gnu with a full "make bootstrap", all default
languages, and regression tested with a top-level "make -k check"
with no new failures.

Committed to mainline as revision 112469.


2006-03-28  Roger Sayle   <roger@eyesopen.com>

	* expr.c (emit_group_store): Only create a new pseudo reg if the
	quantity it needs to hold isn't already a suitable pseudo.


Index: expr.c
===================================================================
*** expr.c	(revision 112150)
--- expr.c	(working copy)
*************** emit_group_store (rtx orig_dst, rtx src,
*** 1888,1895 ****
    for (i = start; i < XVECLEN (src, 0); i++)
      {
        rtx reg = XEXP (XVECEXP (src, 0, i), 0);
!       tmps[i] = gen_reg_rtx (GET_MODE (reg));
!       emit_move_insn (tmps[i], reg);
      }

    /* If we won't be storing directly into memory, protect the real destination
--- 1888,1900 ----
    for (i = start; i < XVECLEN (src, 0); i++)
      {
        rtx reg = XEXP (XVECEXP (src, 0, i), 0);
!       if (!REG_P (reg) || REGNO (reg) < FIRST_PSEUDO_REGISTER)
! 	{
! 	  tmps[i] = gen_reg_rtx (GET_MODE (reg));
! 	  emit_move_insn (tmps[i], reg);
! 	}
!       else
! 	tmps[i] = reg;
      }

    /* If we won't be storing directly into memory, protect the real destination
*************** emit_group_store (rtx orig_dst, rtx src,
*** 1916,1922 ****
      }
    else if (!MEM_P (dst) && GET_CODE (dst) != CONCAT)
      {
!       dst = gen_reg_rtx (GET_MODE (orig_dst));
        /* Make life a bit easier for combine.  */
        emit_move_insn (dst, CONST0_RTX (GET_MODE (orig_dst)));
      }
--- 1921,1928 ----
      }
    else if (!MEM_P (dst) && GET_CODE (dst) != CONCAT)
      {
!       if (!REG_P (dst) || REGNO (dst) < FIRST_PSEUDO_REGISTER)
! 	dst = gen_reg_rtx (GET_MODE (orig_dst));
        /* Make life a bit easier for combine.  */
        emit_move_insn (dst, CONST0_RTX (GET_MODE (orig_dst)));
      }


Roger
--


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