re PR rtl-optimization/60969 (ICE in output_129 in MMXMOV of mode MODE_SF for march...
authorVladimir Makarov <vmakarov@redhat.com>
Thu, 22 May 2014 21:09:59 +0000 (21:09 +0000)
committerVladimir Makarov <vmakarov@gcc.gnu.org>
Thu, 22 May 2014 21:09:59 +0000 (21:09 +0000)
2014-05-22  Vladimir Makarov  <vmakarov@redhat.com>

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
gcc/ira-costs.c

index ace8d994c65e004462b549afb65d7ba020279878..e941c3f81c9e2f844e08bfe4a48afb7c0adb3d32 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-22  Vladimir Makarov  <vmakarov@redhat.com>
+
+       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  <thomas@codesourcery.com>
 
        * builtin-types.def: Simplify examples for DEF_FUNCTION_TYPE_*.
index d5978d581ff8487d495d698fbf18649e66a6539c..2b1574fed3330be0607fcbdb37733dd5f467b133 100644 (file)
@@ -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)