From 0a1eb35020de1c6379c8cab591f6474e94a03c5b Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Thu, 22 May 2014 21:09:59 +0000 Subject: [PATCH] re PR rtl-optimization/60969 (ICE in output_129 in MMXMOV of mode MODE_SF for march=pentium4) 2014-05-22 Vladimir Makarov PR rtl-optimization/60969 * ira-costs.c (record_reg_classes): Process NO_REGS for matching constraints. Set up mem cost for NO_REGS case. From-SVN: r210824 --- gcc/ChangeLog | 6 ++++ gcc/ira-costs.c | 90 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 24 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ace8d994c65e..e941c3f81c9e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-05-22 Vladimir Makarov + + PR rtl-optimization/60969 + * ira-costs.c (record_reg_classes): Process NO_REGS for matching + constraints. Set up mem cost for NO_REGS case. + 2014-05-22 Thomas Schwinge * builtin-types.def: Simplify examples for DEF_FUNCTION_TYPE_*. diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c index d5978d581ff8..2b1574fed333 100644 --- a/gcc/ira-costs.c +++ b/gcc/ira-costs.c @@ -407,6 +407,8 @@ record_reg_classes (int n_alts, int n_ops, rtx *ops, int alt; int i, j, k; int insn_allows_mem[MAX_RECOG_OPERANDS]; + move_table *move_in_cost, *move_out_cost; + short (*mem_cost)[2]; for (i = 0; i < n_ops; i++) insn_allows_mem[i] = 0; @@ -517,41 +519,78 @@ record_reg_classes (int n_alts, int n_ops, rtx *ops, bool in_p = recog_data.operand_type[i] != OP_OUT; bool out_p = recog_data.operand_type[i] != OP_IN; enum reg_class op_class = classes[i]; - move_table *move_in_cost, *move_out_cost; ira_init_register_move_cost_if_necessary (mode); if (! in_p) { ira_assert (out_p); - move_out_cost = ira_may_move_out_cost[mode]; - for (k = cost_classes_ptr->num - 1; k >= 0; k--) + if (op_class == NO_REGS) { - rclass = cost_classes[k]; - pp_costs[k] - = move_out_cost[op_class][rclass] * frequency; + mem_cost = ira_memory_move_cost[mode]; + for (k = cost_classes_ptr->num - 1; k >= 0; k--) + { + rclass = cost_classes[k]; + pp_costs[k] = mem_cost[rclass][0] * frequency; + } + } + else + { + move_out_cost = ira_may_move_out_cost[mode]; + for (k = cost_classes_ptr->num - 1; k >= 0; k--) + { + rclass = cost_classes[k]; + pp_costs[k] + = move_out_cost[op_class][rclass] * frequency; + } } } else if (! out_p) { ira_assert (in_p); - move_in_cost = ira_may_move_in_cost[mode]; - for (k = cost_classes_ptr->num - 1; k >= 0; k--) + if (op_class == NO_REGS) { - rclass = cost_classes[k]; - pp_costs[k] - = move_in_cost[rclass][op_class] * frequency; + mem_cost = ira_memory_move_cost[mode]; + for (k = cost_classes_ptr->num - 1; k >= 0; k--) + { + rclass = cost_classes[k]; + pp_costs[k] = mem_cost[rclass][1] * frequency; + } + } + else + { + move_in_cost = ira_may_move_in_cost[mode]; + for (k = cost_classes_ptr->num - 1; k >= 0; k--) + { + rclass = cost_classes[k]; + pp_costs[k] + = move_in_cost[rclass][op_class] * frequency; + } } } else { - move_in_cost = ira_may_move_in_cost[mode]; - move_out_cost = ira_may_move_out_cost[mode]; - for (k = cost_classes_ptr->num - 1; k >= 0; k--) + if (op_class == NO_REGS) { - rclass = cost_classes[k]; - pp_costs[k] = ((move_in_cost[rclass][op_class] - + move_out_cost[op_class][rclass]) - * frequency); + mem_cost = ira_memory_move_cost[mode]; + for (k = cost_classes_ptr->num - 1; k >= 0; k--) + { + rclass = cost_classes[k]; + pp_costs[k] = ((mem_cost[rclass][0] + + mem_cost[rclass][1]) + * frequency); + } + } + else + { + move_in_cost = ira_may_move_in_cost[mode]; + move_out_cost = ira_may_move_out_cost[mode]; + for (k = cost_classes_ptr->num - 1; k >= 0; k--) + { + rclass = cost_classes[k]; + pp_costs[k] = ((move_in_cost[rclass][op_class] + + move_out_cost[op_class][rclass]) + * frequency); + } } } @@ -783,8 +822,6 @@ record_reg_classes (int n_alts, int n_ops, rtx *ops, bool in_p = recog_data.operand_type[i] != OP_OUT; bool out_p = recog_data.operand_type[i] != OP_IN; enum reg_class op_class = classes[i]; - move_table *move_in_cost, *move_out_cost; - short (*mem_cost)[2]; ira_init_register_move_cost_if_necessary (mode); if (! in_p) @@ -860,10 +897,15 @@ record_reg_classes (int n_alts, int n_ops, rtx *ops, } } - /* If the alternative actually allows memory, make - things a bit cheaper since we won't need an extra - insn to load it. */ - if (op_class != NO_REGS) + if (op_class == NO_REGS) + /* Although we don't need insn to reload from + memory, still accessing memory is usually more + expensive than a register. */ + pp->mem_cost = frequency; + else + /* If the alternative actually allows memory, make + things a bit cheaper since we won't need an + extra insn to load it. */ pp->mem_cost = ((out_p ? ira_memory_move_cost[mode][op_class][0] : 0) + (in_p ? ira_memory_move_cost[mode][op_class][1] : 0) -- 2.47.2