Re: [PATCH] Cleanup, use add_to_hard_reg_set instead of SET_HARD_REG_BIT loops.

2011-04-07 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 04/06/11 12:21, Anatoly Sokolov wrote:
 Hi.
 
   This patch converts loops of SET_HARD_REG_BIT in to add_to_hard_reg_set 
 functions call.
 
   The patch has been bootstrapped on and regression tested on
 x86_64-unknown-linux-gnu for c.
 
   OK to install?
 
 * expr.c (expand_expr_real_1): Use add_to_hard_reg_set function
 instead of loop.
 * sel-sched.c (mark_unavailable_hard_regs): Likewise.
 * function.c (record_hard_reg_sets): Likewise.
 * ira.c (compute_regs_asm_clobbered): Likewise.
 * sched-deps.c (sched_analyze_1): Likewise.
 * reload1.c (mark_reload_reg_in_use, choose_reload_regs): Likewise.
 
 


 Index: gcc/expr.c
 ===
 --- gcc/expr.c  (revision 172049)
 +++ gcc/expr.c  (working copy)
 @@ -8451,18 +8451,10 @@
gcc_assert (decl_rtl);
decl_rtl = copy_rtx (decl_rtl);
/* Record writes to register variables.  */
 -  if (modifier == EXPAND_WRITE  REG_P (decl_rtl)
 -  REGNO (decl_rtl)  FIRST_PSEUDO_REGISTER)
 -   {
 -   int i = REGNO (decl_rtl);
 -   int nregs = hard_regno_nregs[i][GET_MODE (decl_rtl)];
 -   while (nregs)
 - {
 -   SET_HARD_REG_BIT (crtl-asm_clobbers, i);
 -   i++;
 -   nregs--;
 - }
 -   }
 +  if (modifier == EXPAND_WRITE
 +  REG_P (decl_rtl)  HARD_REGISTER_P (decl_rtl))
 +add_to_hard_reg_set (crtl-asm_clobbers,
 +GET_MODE (decl_rtl), REGNO (decl_rtl));
Minor formatting nit, can you put the  HARD_REGISTER_P (decl_rtl) on a
separate line.  Generally once we have multi-line conditionals we try to
put a single conditional on each line.

OK with that change.

Thanks,
jeff

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNndOsAAoJEBRtltQi2kC7U8kH/34KJ5Rl8tcA6KZTYE8Q+/dq
fekev3UJPXlzpARvbz1L4H8+bZFWNVOfmC1FktsO5slA6I8uxZp6mfFZvKmvWaNh
cJJ/tevjY80NVkaksEPIdvM5nE7RZXHzLvHsBUhHtL0NER1wVUsWlLI06/qlIoCG
/vyM/GUUAzjzkyA6AQPCPvOQPgcJmTLuYNJ5w1o9H7SQlFPXJO/KNUpAblr6Wpiq
veyVSMTd4LU+FjBGUsGLUOWWovOJicbHZlONE7Ti9rOUFepyCevtsSXqdisn0srM
X2PMQ6EdD4wfoVZK0gBFQUKAEEs7c4iN03+Y6oIRq3V/wjxeazExbOHilXnYm2o=
=99Re
-END PGP SIGNATURE-


[PATCH] Cleanup, use add_to_hard_reg_set instead of SET_HARD_REG_BIT loops.

2011-04-06 Thread Anatoly Sokolov
Hi.

  This patch converts loops of SET_HARD_REG_BIT in to add_to_hard_reg_set 
functions call.

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

  OK to install?

* expr.c (expand_expr_real_1): Use add_to_hard_reg_set function
instead of loop.
* sel-sched.c (mark_unavailable_hard_regs): Likewise.
* function.c (record_hard_reg_sets): Likewise.
* ira.c (compute_regs_asm_clobbered): Likewise.
* sched-deps.c (sched_analyze_1): Likewise.
* reload1.c (mark_reload_reg_in_use, choose_reload_regs): Likewise.


Index: gcc/sel-sched.c
===
--- gcc/sel-sched.c (revision 172049)
+++ gcc/sel-sched.c (working copy)
@@ -1263,17 +1263,12 @@
  FIXME: it is enough to do this once per all original defs.  */
   if (frame_pointer_needed)
 {
-  int i;
+  add_to_hard_reg_set (reg_rename_p-unavailable_hard_regs,
+  Pmode, FRAME_POINTER_REGNUM);
 
-  for (i = hard_regno_nregs[FRAME_POINTER_REGNUM][Pmode]; i--;)
-   SET_HARD_REG_BIT (reg_rename_p-unavailable_hard_regs,
-  FRAME_POINTER_REGNUM + i);
-
-#if !HARD_FRAME_POINTER_IS_FRAME_POINTER
-  for (i = hard_regno_nregs[HARD_FRAME_POINTER_REGNUM][Pmode]; i--;)
-   SET_HARD_REG_BIT (reg_rename_p-unavailable_hard_regs,
-  HARD_FRAME_POINTER_REGNUM + i);
-#endif
+  if (!HARD_FRAME_POINTER_IS_FRAME_POINTER)
+add_to_hard_reg_set (reg_rename_p-unavailable_hard_regs, 
+Pmode, HARD_FRAME_POINTER_IS_FRAME_POINTER);
 }
 
 #ifdef STACK_REGS
Index: gcc/expr.c
===
--- gcc/expr.c  (revision 172049)
+++ gcc/expr.c  (working copy)
@@ -8451,18 +8451,10 @@
   gcc_assert (decl_rtl);
   decl_rtl = copy_rtx (decl_rtl);
   /* Record writes to register variables.  */
-  if (modifier == EXPAND_WRITE  REG_P (decl_rtl)
-  REGNO (decl_rtl)  FIRST_PSEUDO_REGISTER)
-   {
-   int i = REGNO (decl_rtl);
-   int nregs = hard_regno_nregs[i][GET_MODE (decl_rtl)];
-   while (nregs)
- {
-   SET_HARD_REG_BIT (crtl-asm_clobbers, i);
-   i++;
-   nregs--;
- }
-   }
+  if (modifier == EXPAND_WRITE
+  REG_P (decl_rtl)  HARD_REGISTER_P (decl_rtl))
+add_to_hard_reg_set (crtl-asm_clobbers,
+GET_MODE (decl_rtl), REGNO (decl_rtl));
 
   /* Ensure variable marked as used even if it doesn't go through
 a parser.  If it hasn't be used yet, write out an external
Index: gcc/function.c
===
--- gcc/function.c  (revision 172049)
+++ gcc/function.c  (working copy)
@@ -2912,12 +2912,8 @@
 record_hard_reg_sets (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data)
 {
   HARD_REG_SET *pset = (HARD_REG_SET *)data;
-  if (REG_P (x)  REGNO (x)  FIRST_PSEUDO_REGISTER)
-{
-  int nregs = hard_regno_nregs[REGNO (x)][GET_MODE (x)];
-  while (nregs--  0)
-   SET_HARD_REG_BIT (*pset, REGNO (x) + nregs);
-}
+  if (REG_P (x)  HARD_REGISTER_P (x))
+add_to_hard_reg_set (pset, GET_MODE (x), REGNO (x));
 }
 
 /* A subroutine of assign_parms.  Allocate a pseudo to hold the current
Index: gcc/ira.c
===
--- gcc/ira.c   (revision 172049)
+++ gcc/ira.c   (working copy)
@@ -1724,16 +1724,10 @@
  {
df_ref def = *def_rec;
unsigned int dregno = DF_REF_REGNO (def);
-   if (dregno  FIRST_PSEUDO_REGISTER)
- {
-   unsigned int i;
-   enum machine_mode mode = GET_MODE (DF_REF_REAL_REG (def));
-   unsigned int end = dregno
- + hard_regno_nregs[dregno][mode] - 1;
-
-   for (i = dregno; i = end; ++i)
- SET_HARD_REG_BIT(crtl-asm_clobbers, i);
- }
+   if (HARD_REGISTER_NUM_P (dregno))
+ add_to_hard_reg_set (crtl-asm_clobbers,
+  GET_MODE (DF_REF_REAL_REG (def)),
+  dregno);
  }
}
 }
Index: gcc/sched-deps.c
===
--- gcc/sched-deps.c(revision 172049)
+++ gcc/sched-deps.c(working copy)
@@ -2259,16 +2259,12 @@
   /* Treat all writes to a stack register as modifying the TOS.  */
   if (regno = FIRST_STACK_REG  regno = LAST_STACK_REG)
{
- int nregs;
-
  /* Avoid analyzing the same register twice.  */
  if (regno != FIRST_STACK_REG)
sched_analyze_reg (deps, FIRST_STACK_REG, mode, code, insn);
 
- nregs =