From abdd692edcf16191746fc1aa0944fe1a50359451 Mon Sep 17 00:00:00 2001 From: Pat Haugen Date: Tue, 31 May 2011 20:47:37 +0000 Subject: [PATCH] rs6000.c (rs6000_register_move_cost): Preserve from parameter value for dump. * config/rs6000/rs6000.c (rs6000_register_move_cost): Preserve from parameter value for dump. Dump cost on outermost call only. (rs6000_memory_move_cost): Dump cost on outermost call only. From-SVN: r174511 --- gcc/ChangeLog | 6 ++++++ gcc/config/rs6000/rs6000.c | 42 +++++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8d6dc36ab65..bcd489b7600 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-05-31 Pat Haugen + + * config/rs6000/rs6000.c (rs6000_register_move_cost): Preserve from + parameter value for dump. Dump cost on outermost call only. + (rs6000_memory_move_cost): Dump cost on outermost call only. + 2011-05-31 Jakub Jelinek * dwarf2out.c (resolve_addr_in_expr): Optimize away redundant diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index d6a12fdbe09..a21d85db7bb 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -189,6 +189,8 @@ enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER]; /* Reload functions based on the type and the vector unit. */ static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2]; +static int dbg_cost_ctrl; + /* Built in types. */ tree rs6000_builtin_types[RS6000_BTI_MAX]; tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT]; @@ -26428,27 +26430,32 @@ rs6000_register_move_cost (enum machine_mode mode, { int ret; + if (TARGET_DEBUG_COST) + dbg_cost_ctrl++; + /* Moves from/to GENERAL_REGS. */ if (reg_classes_intersect_p (to, GENERAL_REGS) || reg_classes_intersect_p (from, GENERAL_REGS)) { + reg_class_t rclass = from; + if (! reg_classes_intersect_p (to, GENERAL_REGS)) - from = to; + rclass = to; - if (from == FLOAT_REGS || from == ALTIVEC_REGS || from == VSX_REGS) - ret = (rs6000_memory_move_cost (mode, from, false) + if (rclass == FLOAT_REGS || rclass == ALTIVEC_REGS || rclass == VSX_REGS) + ret = (rs6000_memory_move_cost (mode, rclass, false) + rs6000_memory_move_cost (mode, GENERAL_REGS, false)); /* It's more expensive to move CR_REGS than CR0_REGS because of the shift. */ - else if (from == CR_REGS) + else if (rclass == CR_REGS) ret = 4; /* For those processors that have slow LR/CTR moves, make them more expensive than memory in order to bias spills to memory .*/ else if ((rs6000_cpu == PROCESSOR_POWER6 || rs6000_cpu == PROCESSOR_POWER7) - && reg_classes_intersect_p (from, LINK_OR_CTR_REGS)) + && reg_classes_intersect_p (rclass, LINK_OR_CTR_REGS)) ret = 6 * hard_regno_nregs[0][mode]; else @@ -26472,10 +26479,14 @@ rs6000_register_move_cost (enum machine_mode mode, + rs6000_register_move_cost (mode, from, GENERAL_REGS)); if (TARGET_DEBUG_COST) - fprintf (stderr, - "rs6000_register_move_cost:, ret=%d, mode=%s, from=%s, to=%s\n", - ret, GET_MODE_NAME (mode), reg_class_names[from], - reg_class_names[to]); + { + if (dbg_cost_ctrl == 1) + fprintf (stderr, + "rs6000_register_move_cost:, ret=%d, mode=%s, from=%s, to=%s\n", + ret, GET_MODE_NAME (mode), reg_class_names[from], + reg_class_names[to]); + dbg_cost_ctrl--; + } return ret; } @@ -26489,6 +26500,9 @@ rs6000_memory_move_cost (enum machine_mode mode, reg_class_t rclass, { int ret; + if (TARGET_DEBUG_COST) + dbg_cost_ctrl++; + if (reg_classes_intersect_p (rclass, GENERAL_REGS)) ret = 4 * hard_regno_nregs[0][mode]; else if (reg_classes_intersect_p (rclass, FLOAT_REGS)) @@ -26499,9 +26513,13 @@ rs6000_memory_move_cost (enum machine_mode mode, reg_class_t rclass, ret = 4 + rs6000_register_move_cost (mode, rclass, GENERAL_REGS); if (TARGET_DEBUG_COST) - fprintf (stderr, - "rs6000_memory_move_cost: ret=%d, mode=%s, rclass=%s, in=%d\n", - ret, GET_MODE_NAME (mode), reg_class_names[rclass], in); + { + if (dbg_cost_ctrl == 1) + fprintf (stderr, + "rs6000_memory_move_cost: ret=%d, mode=%s, rclass=%s, in=%d\n", + ret, GET_MODE_NAME (mode), reg_class_names[rclass], in); + dbg_cost_ctrl--; + } return ret; } -- 2.30.2