Patchwork Use ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro

login
register
mail settings
Submitter Anatoly Sokolov
Date June 30, 2011, 9:51 p.m.
Message ID <777344864.20110701015138@post.ru>
Download mbox | patch
Permalink /patch/102840/
State New
Headers show

Comments

Anatoly Sokolov - June 30, 2011, 9:51 p.m.
Hello.

  This patch replaces the use of macro CLASS_MAX_NREGS to reading from
ira_reg_class_max_nregs array. The ira_reg_class_max_nregs array is 
initialized from a macro CLASS_MAX_NREGS. This patch  should speed up the 
compiler, a little.

  The patch has been bootstrapped on and regression tested on
x86_64-unknown-linux-gnu for c.

  OK to install?

        * ira.h (target_ira): Change type x_ira_reg_class_max_nregs and
        x_ira_reg_class_min_nregs arrays to unsigned char.
        * ira-conflicts.c (process_regs_for_copy): Use
        ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro.
        Change type rclass and aclass vars to reg_class_t.
        * ira-costs.c (record_reg_classes): Use ira_reg_class_max_nregs
        array instead of CLASS_MAX_NREGS macro. Change type rclass var to
        reg_class_t.
        * reload.c (combine_reloads, find_reloads, find_reloads_address_1):
        Use ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro.

  The ira_reg_class_max_nregs array are using not only the IRA passes as well 
as in scheduling, loop invariant and now in reload passes. I propose to 
rename ira_reg_class_max_nregs and ira_reg_class_min_nregs array in 
reg_class_max_nregs and reg_class_min_nregs, move this declaration from ira.h 
to hard-reg-set.h and initialization from ira.c to reginfo.c. It will call the 
CLASS_MAX_NREGS macro only in one place the GCC. What is your opinion about 
these changes? 



Anatoly.
Anatoly Sokolov - July 6, 2011, 6:39 p.m.
Hi.

The patch 
http://gcc.gnu.org/ml/gcc-patches/2011-06/msg02405.html is still pending 
review.


Anatoly.

Patch

Index: gcc/ira-conflicts.c
===================================================================
--- gcc/ira-conflicts.c	(revision 175666)
+++ gcc/ira-conflicts.c	(working copy)
@@ -393,7 +393,7 @@ 
   int allocno_preferenced_hard_regno, cost, index, offset1, offset2;
   bool only_regs_p;
   ira_allocno_t a;
-  enum reg_class rclass, aclass;
+  reg_class_t rclass, aclass;
   enum machine_mode mode;
   ira_copy_t cp;
 
@@ -438,7 +438,7 @@ 
   mode = ALLOCNO_MODE (a);
   aclass = ALLOCNO_CLASS (a);
   if (only_regs_p && insn != NULL_RTX
-      && reg_class_size[rclass] <= (unsigned) CLASS_MAX_NREGS (rclass, mode))
+      && reg_class_size[rclass] <= ira_reg_class_max_nregs [rclass][mode])
     /* It is already taken into account in ira-costs.c.  */
     return false;
   index = ira_class_hard_reg_index[aclass][allocno_preferenced_hard_regno];
Index: gcc/reload.c
===================================================================
--- gcc/reload.c        (revision 175666)
+++ gcc/reload.c        (working copy)
@@ -1769,9 +1769,9 @@ 
        && rld[i].when_needed != RELOAD_FOR_OUTPUT_ADDRESS
        && rld[i].when_needed != RELOAD_FOR_OUTADDR_ADDRESS
        && rld[i].when_needed != RELOAD_OTHER
-       && (CLASS_MAX_NREGS (rld[i].rclass, rld[i].inmode)
-           == CLASS_MAX_NREGS (rld[output_reload].rclass,
-                               rld[output_reload].outmode))
+       && (ira_reg_class_max_nregs [(int) rld[i].rclass][(int) rld[i].inmode]
+           == ira_reg_class_max_nregs [(int) rld[output_reload].rclass]
+                                      [(int) rld[output_reload].outmode])
        && rld[i].inc == 0
        && rld[i].reg_rtx == 0
 #ifdef SECONDARY_MEMORY_NEEDED
@@ -4544,7 +4544,7 @@ 
               > GET_MODE_SIZE (rld[i].inmode)))
          ? rld[i].outmode : rld[i].inmode;
 
-      rld[i].nregs = CLASS_MAX_NREGS (rld[i].rclass, rld[i].mode);
+      rld[i].nregs = ira_reg_class_max_nregs [rld[i].rclass][rld[i].mode];
     }
 
   /* Special case a simple move with an input reload and a
@@ -5994,8 +5994,8 @@ 
          else
            {
              enum reg_class rclass = context_reg_class;
-             if ((unsigned) CLASS_MAX_NREGS (rclass, GET_MODE (SUBREG_REG (x)))
-                 > reg_class_size[rclass])
+             if (ira_reg_class_max_nregs [rclass][GET_MODE (SUBREG_REG (x))]
+                 > reg_class_size[(int) rclass])
                {
                  x = find_reloads_subreg_address (x, 0, opnum,
                                                   ADDR_TYPE (type),
Index: gcc/ira.h
===================================================================
--- gcc/ira.h   (revision 175666)
+++ gcc/ira.h   (working copy)
@@ -68,8 +68,8 @@ 
   /* Maps: register class x machine mode -> maximal/minimal number of
      hard registers of given class needed to store value of given
      mode.  */
-  int x_ira_reg_class_max_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
-  int x_ira_reg_class_min_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
+  unsigned char x_ira_reg_class_max_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
+  unsigned char x_ira_reg_class_min_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
 
   /* Array analogous to target hook TARGET_MEMORY_MOVE_COST.  */
   short x_ira_memory_move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][2];
Index: gcc/ira-costs.c
===================================================================
--- gcc/ira-costs.c     (revision 175666)
+++ gcc/ira-costs.c     (working copy)
@@ -930,15 +930,15 @@ 
          enum machine_mode mode = GET_MODE (ops[!i]);
          cost_classes_t cost_classes_ptr = regno_cost_classes[regno];
          enum reg_class *cost_classes = cost_classes_ptr->classes;
-         enum reg_class rclass;
+         reg_class_t rclass;
          int nr;
 
          for (k = cost_classes_ptr->num - 1; k >= 0; k--)
            {
              rclass = cost_classes[k];
              if (TEST_HARD_REG_BIT (reg_class_contents[rclass], other_regno)
-                 && (reg_class_size[rclass]
-                     == (unsigned) CLASS_MAX_NREGS (rclass, mode)))
+                 && (reg_class_size[(int) rclass]
+                     == ira_reg_class_max_nregs [(int) rclass][(int) mode]))
                {
                  if (reg_class_size[rclass] == 1)
                    op_costs[i]->cost[k] = -frequency;