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]

[PATCH] ira-costs: avoid missing base registers in record_address_regs


Hello,

The code in record_address_regs shown in the following patch assumes that
if a given target cannot have two registers in a memory address, then the
sole register, if present, must be the leftmost operand in the PLUS chain.

I think this is not true if the target uses unspecs to signify special
addressing modes such as TLS.  In that case the unspec can be to the left
of the register, and this function won't see the register.

The proposed fix is to always recurse into non-constant operands like in the
adjacent case of index registers being the same as base registers. OK to apply?

(most popular targets have MAX_REGS_PER_ADDRESS == 2, so this problem doesn't
arise)

Alexander

	* ira-costs.c (record_address_regs): Handle both operands of PLUS for
	MAX_REGS_PER_ADDRESS == 1.

diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c
index 2cd102a0810..1690e889471 100644
--- a/gcc/ira-costs.c
+++ b/gcc/ira-costs.c
@@ -1138,17 +1138,12 @@ record_address_regs (machine_mode mode, addr_space_t as, rtx x,
 	if (code1 == SUBREG)
 	  arg1 = SUBREG_REG (arg1), code1 = GET_CODE (arg1);
 
-	/* If this machine only allows one register per address, it
-	   must be in the first operand.  */
-	if (MAX_REGS_PER_ADDRESS == 1)
-	  record_address_regs (mode, as, arg0, 0, PLUS, code1, scale);
-
-	/* If index and base registers are the same on this machine,
+	/* If index registers do not appear, or coincide with base registers,
 	   just record registers in any non-constant operands.  We
 	   assume here, as well as in the tests below, that all
 	   addresses are in canonical form.  */
-	else if (INDEX_REG_CLASS
-		 == base_reg_class (VOIDmode, as, PLUS, SCRATCH))
+	if (MAX_REGS_PER_ADDRESS == 1
+	    || INDEX_REG_CLASS == base_reg_class (VOIDmode, as, PLUS, SCRATCH))
 	  {
 	    record_address_regs (mode, as, arg0, context, PLUS, code1, scale);
 	    if (! CONSTANT_P (arg1))


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