In spite of the relocation, this sequence is shorter than loading the constant and symbol_ref independently when the constant doesn't fit in 14 bits. So, I believe this is a win.
I've also added a REG_EQUAL note to improve optimization. Tested on hppa-unknown-linux-gnu, hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11. Committed to trunk. Dave -- John David Anglin dave.ang...@bell.net
2015-02-19 John David Anglin <danl...@gcc.gnu.org> * config/pa/pa.c (pa_emit_move_sequence): Always force (const (plus (symbol) (const_int))) to const mem. Put REG_EQUAL note on insn. Index: config/pa/pa.c =================================================================== --- config/pa/pa.c (revision 220778) +++ config/pa/pa.c (working copy) @@ -2012,6 +2017,7 @@ if (flag_pic) { + rtx_insn *insn; rtx temp; if (reload_in_progress || reload_completed) @@ -2025,21 +2031,20 @@ else temp = gen_reg_rtx (Pmode); - /* (const (plus (symbol) (const_int))) must be forced to - memory during/after reload if the const_int will not fit - in 14 bits. */ + /* Force (const (plus (symbol) (const_int))) to memory + if the const_int will not fit in 14 bits. Although + this requires a relocation, the instruction sequence + needed to load the value is shorter. */ if (GET_CODE (operand1) == CONST && GET_CODE (XEXP (operand1, 0)) == PLUS && GET_CODE (XEXP (XEXP (operand1, 0), 1)) == CONST_INT - && !INT_14_BITS (XEXP (XEXP (operand1, 0), 1)) - && (reload_completed || reload_in_progress) - && flag_pic) + && !INT_14_BITS (XEXP (XEXP (operand1, 0), 1))) { - rtx const_mem = force_const_mem (mode, operand1); - operands[1] = legitimize_pic_address (XEXP (const_mem, 0), - mode, temp); - operands[1] = replace_equiv_address (const_mem, operands[1]); - pa_emit_move_sequence (operands, mode, temp); + rtx x, m = force_const_mem (mode, operand1); + + x = legitimize_pic_address (XEXP (m, 0), mode, temp); + x = replace_equiv_address (m, x); + insn = emit_move_insn (operand0, x); } else { @@ -2046,8 +2051,11 @@ operands[1] = legitimize_pic_address (operand1, mode, temp); if (REG_P (operand0) && REG_P (operands[1])) copy_reg_pointer (operand0, operands[1]); - emit_insn (gen_rtx_SET (VOIDmode, operand0, operands[1])); + insn = emit_move_insn (operand0, operands[1]); } + + /* Put a REG_EQUAL note on this insn. */ + set_unique_reg_note (insn, REG_EQUAL, operand1); } /* On the HPPA, references to data space are supposed to use dp, register 27, but showing it in the RTL inhibits various cse