From e3c8ea672563a4f8762b60f302a0a13c788405f7 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 21 Feb 2002 15:06:16 -0800 Subject: emit-rtl.c (offset_address): Use simplify_gen_binary rather than gen_rtx_PLUS to form the sum. * emit-rtl.c (offset_address): Use simplify_gen_binary rather than gen_rtx_PLUS to form the sum. * explow.c (force_reg): Rearrange to not allocate new pseudo when force_operand returns a register. * expr.c (expand_assignment): Allow offset_rtx expansion to return a sum. Do not force addresses into registers. (expand_expr): Likewise. * simplify-rtx.c (simplify_gen_binary): Use simplify_plus_minus to canonicalize arithmetic that didn't simpify. (simplify_plus_minus): New argument force; update all callers. Don't split CONST unless we can do something with it, and wouldn't lose the constness of the operands. * config/i386/i386.c (legitimize_pic_address): Recognize UNSPECs that we generated earlier. From-SVN: r49945 --- gcc/emit-rtl.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'gcc/emit-rtl.c') diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 82dd61a..836fbf5 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -2047,9 +2047,26 @@ offset_address (memref, offset, pow2) rtx offset; HOST_WIDE_INT pow2; { - rtx new = change_address_1 (memref, VOIDmode, - gen_rtx_PLUS (Pmode, XEXP (memref, 0), - force_reg (Pmode, offset)), 1); + rtx new, addr = XEXP (memref, 0); + + new = simplify_gen_binary (PLUS, Pmode, addr, offset); + + /* At this point we don't know _why_ the address is invalid. It + could have secondary memory refereces, multiplies or anything. + + However, if we did go and rearrange things, we can wind up not + being able to recognize the magic around pic_offset_table_rtx. + This stuff is fragile, and is yet another example of why it is + bad to expose PIC machinery too early. */ + if (! memory_address_p (GET_MODE (memref), new) + && GET_CODE (addr) == PLUS + && XEXP (addr, 0) == pic_offset_table_rtx) + { + addr = force_reg (GET_MODE (addr), addr); + new = simplify_gen_binary (PLUS, Pmode, addr, offset); + } + + new = change_address_1 (memref, VOIDmode, new, 1); /* Update the alignment to reflect the offset. Reset the offset, which we don't know. */ -- cgit v1.1