This patch adjusts the spill cost of literal pool loads to reduce the chance of them being caller-saved (which is inefficient). Such loads should be rematerialized and thus should not include the cost of a spill store. This was done only on constants for which legitimate_constant_p is true, however it is right thing to do for any constant, including constants in literal pools (which are typically not legitimate). Also use ALL_REGS rather than GENERAL_REGS as ALL_REGS has the correct floating point register costs.
ChangeLog: 2014-10-29 Wilco Dijkstra <wdijk...@arm.com> * gcc/ira-costs.c (scan_one_insn): Improve spill cost adjustment. --- gcc/ira-costs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c index 122815b..c4a1934 100644 --- a/gcc/ira-costs.c +++ b/gcc/ira-costs.c @@ -1455,19 +1455,18 @@ scan_one_insn (rtx_insn *insn) mem_cost might result in it being loaded using the specialized instruction into a register, then stored into stack and loaded again from the stack. See PR52208. - + Don't do this if SET_SRC (set) has side effect. See PR56124. */ if (set != 0 && REG_P (SET_DEST (set)) && MEM_P (SET_SRC (set)) && (note = find_reg_note (insn, REG_EQUIV, NULL_RTX)) != NULL_RTX && ((MEM_P (XEXP (note, 0)) && !side_effects_p (SET_SRC (set))) || (CONSTANT_P (XEXP (note, 0)) - && targetm.legitimate_constant_p (GET_MODE (SET_DEST (set)), - XEXP (note, 0)) + && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (XEXP (note, 0))) && REG_N_SETS (REGNO (SET_DEST (set))) == 1)) && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set)))) { - enum reg_class cl = GENERAL_REGS; + enum reg_class cl = ALL_REGS; rtx reg = SET_DEST (set); int num = COST_INDEX (REGNO (reg)); -- 1.9.1