I needed to move an instance of:

      COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl]);
      AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs);
      if (hard_reg_set_empty_p (temp_hard_regset))
        continue;

But this can more easily be calculated as:

      ira_class_hard_regs_num[cl] == 0

so this patch uses that instead.

Richard


gcc/
        * ira.c (setup_allocno_and_important_classes): Use
        ira_class_hard_regs_num to check whether a class has any
        allocatable registers.
        (ira_init_register_move_cost): Likewise.

Index: gcc/ira.c
===================================================================
--- gcc/ira.c   2012-05-29 19:27:46.987766420 +0100
+++ gcc/ira.c   2012-05-29 19:35:14.021753423 +0100
@@ -970,39 +970,32 @@ setup_allocno_and_important_classes (voi
      registers.  */
   ira_allocno_classes_num = 0;
   for (i = 0; (cl = classes[i]) != LIM_REG_CLASSES; i++)
-    {
-      COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl]);
-      AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs);
-      if (hard_reg_set_empty_p (temp_hard_regset))
-       continue;
+    if (ira_class_hard_regs_num[cl] > 0)
       ira_allocno_classes[ira_allocno_classes_num++] = (enum reg_class) cl;
-    }
   ira_important_classes_num = 0;
   /* Add non-allocno classes containing to non-empty set of
      allocatable hard regs.  */
   for (cl = 0; cl < N_REG_CLASSES; cl++)
-    {
-      COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl]);
-      AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs);
-      if (! hard_reg_set_empty_p (temp_hard_regset))
-       {
-         set_p = false;
-         for (j = 0; j < ira_allocno_classes_num; j++)
-           {
-             COPY_HARD_REG_SET (temp_hard_regset2,
-                                reg_class_contents[ira_allocno_classes[j]]);
-             AND_COMPL_HARD_REG_SET (temp_hard_regset2, no_unit_alloc_regs);
-             if ((enum reg_class) cl == ira_allocno_classes[j])
-               break;
-             else if (hard_reg_set_subset_p (temp_hard_regset,
-                                             temp_hard_regset2))
-               set_p = true;
-           }
-         if (set_p && j >= ira_allocno_classes_num)
-           ira_important_classes[ira_important_classes_num++]
-             = (enum reg_class) cl;
-       }
-    }
+    if (ira_class_hard_regs_num[cl] > 0)
+      {
+       COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl]);
+       AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs);
+       set_p = false;
+       for (j = 0; j < ira_allocno_classes_num; j++)
+         {
+           COPY_HARD_REG_SET (temp_hard_regset2,
+                              reg_class_contents[ira_allocno_classes[j]]);
+           AND_COMPL_HARD_REG_SET (temp_hard_regset2, no_unit_alloc_regs);
+           if ((enum reg_class) cl == ira_allocno_classes[j])
+             break;
+           else if (hard_reg_set_subset_p (temp_hard_regset,
+                                           temp_hard_regset2))
+             set_p = true;
+         }
+       if (set_p && j >= ira_allocno_classes_num)
+         ira_important_classes[ira_important_classes_num++]
+           = (enum reg_class) cl;
+      }
   /* Now add allocno classes to the important classes.  */
   for (j = 0; j < ira_allocno_classes_num; j++)
     ira_important_classes[ira_important_classes_num++]
@@ -1575,15 +1568,10 @@ ira_init_register_move_cost (enum machin
   memcpy (ira_max_register_move_cost[mode], ira_register_move_cost[mode],
          sizeof (move_table) * N_REG_CLASSES);
   for (cl1 = 0; cl1 < N_REG_CLASSES; cl1++)
-    {
-      /* Some subclasses are to small to have enough registers to hold
-        a value of MODE.  Just ignore them.  */
-      if (ira_reg_class_max_nregs[cl1][mode] > ira_class_hard_regs_num[cl1])
-       continue;
-      COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl1]);
-      AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs);
-      if (hard_reg_set_empty_p (temp_hard_regset))
-       continue;
+    /* Some subclasses are to small to have enough registers to hold
+       a value of MODE.  Just ignore them.  */
+    if (ira_class_hard_regs_num[cl1] > 0
+       && ira_reg_class_max_nregs[cl1][mode] <= ira_class_hard_regs_num[cl1])
       for (cl2 = 0; cl2 < N_REG_CLASSES; cl2++)
        if (hard_reg_set_subset_p (reg_class_contents[cl1],
                                   reg_class_contents[cl2]))
@@ -1598,7 +1586,6 @@ ira_init_register_move_cost (enum machin
                ira_max_register_move_cost[mode][cl3][cl2]
                  = ira_register_move_cost[mode][cl3][cl1];
            }
-    }
   ira_may_move_in_cost[mode]
     = (move_table *) xmalloc (sizeof (move_table) * N_REG_CLASSES);
   memcpy (ira_may_move_in_cost[mode], may_move_in_cost[mode],
@@ -1619,9 +1606,7 @@ ira_init_register_move_cost (enum machin
     {
       for (cl2 = 0; cl2 < N_REG_CLASSES; cl2++)
        {
-         COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl2]);
-         AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs);
-         if (hard_reg_set_empty_p (temp_hard_regset))
+         if (ira_class_hard_regs_num[cl2] == 0)
            continue;
          if (ira_class_subset_p[cl1][cl2])
            ira_may_move_in_cost[mode][cl1][cl2] = 0;

Reply via email to