* [PATCH, rs6000] Tidy up dumping of register/memory move cost
@ 2011-05-25 19:46 Pat Haugen
2011-05-31 23:35 ` David Edelsohn
0 siblings, 1 reply; 2+ messages in thread
From: Pat Haugen @ 2011-05-25 19:46 UTC (permalink / raw)
To: gcc-patches; +Cc: David Edelsohn
[-- Attachment #1: Type: text/plain, Size: 685 bytes --]
The following fixes a problem when dumping register costs, where the incorrect
'from' value was being written out because the code modified the incoming
parameter value. It also changes things so that register/memory costs are only
dumped on the outermost call, eliminating intermediate output when a cost
calculation requires going through memory or GPRs.
Bootstrap/regtest on powerpc64-linux with no new regressions. Ok for trunk?
-Pat
2011-05-25 Pat Haugen <pthaugen@us.ibm.com>
* 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.
[-- Attachment #2: debug_cost.diff --]
[-- Type: text/x-patch, Size: 3243 bytes --]
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 174138)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -189,6 +189,8 @@ enum reg_class rs6000_regno_regclass[FIR
/* 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,26 +26430,31 @@ rs6000_register_move_cost (enum machine_
{
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;
/* Power6 has slower LR/CTR moves so make them more expensive than
memory in order to bias spills to memory .*/
else if (rs6000_cpu == PROCESSOR_POWER6
- && 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
@@ -26471,10 +26478,14 @@ rs6000_register_move_cost (enum machine_
+ 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;
}
@@ -26488,6 +26499,9 @@ rs6000_memory_move_cost (enum machine_mo
{
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))
@@ -26498,9 +26512,13 @@ rs6000_memory_move_cost (enum machine_mo
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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, rs6000] Tidy up dumping of register/memory move cost
2011-05-25 19:46 [PATCH, rs6000] Tidy up dumping of register/memory move cost Pat Haugen
@ 2011-05-31 23:35 ` David Edelsohn
0 siblings, 0 replies; 2+ messages in thread
From: David Edelsohn @ 2011-05-31 23:35 UTC (permalink / raw)
To: Pat Haugen; +Cc: gcc-patches
On Wed, May 25, 2011 at 3:02 PM, Pat Haugen <pthaugen@linux.vnet.ibm.com> wrote:
> The following fixes a problem when dumping register costs, where the
> incorrect 'from' value was being written out because the code modified the
> incoming parameter value. It also changes things so that register/memory
> costs are only dumped on the outermost call, eliminating intermediate output
> when a cost calculation requires going through memory or GPRs.
>
> Bootstrap/regtest on powerpc64-linux with no new regressions. Ok for trunk?
>
> -Pat
>
>
> 2011-05-25 Pat Haugen <pthaugen@us.ibm.com>
>
> * 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.
Okay.
Thanks, David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-31 19:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 19:46 [PATCH, rs6000] Tidy up dumping of register/memory move cost Pat Haugen
2011-05-31 23:35 ` David Edelsohn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).