Hello list,

the attached patch eliminates regs_invalidated_by_call_regset bitmap and uses instead the original regs_invalidated_by_call HARD_REG_SET. Tested on i386, I had the following two regressions that I'll investigate right on:

 FAIL: libmudflap.cth/pass39-frag.c (-O3) (rerun 10) execution test
 FAIL: libmudflap.cth/pass39-frag.c (-O3) (rerun 10) output pattern test



Performance measured not to be affected, maybe it is now a couple milliseconds faster:

Original: PC1:0.878s, PC2:6.55s, 2105.6 M instr
Patched : PC1:0.875s, PC2:6.54s, 2104.9 M instr


2011-07-25  Dimitrios Apostolou <ji...@gmx.net>

* df-core.c, df-problems.c, df-scan.c, df.h, reginfo.c, regset.h: Eliminate regs_invalidated_by_call_regset bitmap and use instead the original regs_invalidated_by_call HARD_REG_SET.


All comments are welcome,
Dimitris
=== modified file 'gcc/df-core.c'
--- gcc/df-core.c       2011-04-20 18:19:03 +0000
+++ gcc/df-core.c       2011-07-25 13:58:58 +0000
@@ -1886,6 +1886,17 @@ df_print_regset (FILE *file, bitmap r)
 }
 
 
+void
+df_print_hard_reg_set (FILE *f, HARD_REG_SET r)
+{
+  unsigned int i;
+  hard_reg_set_iterator iter;
+
+  EXECUTE_IF_SET_IN_HARD_REG_SET (r, 0, i, iter)
+    fprintf (f, " %d [%s]", i, reg_names[i]);
+  fprintf (f, "\n");
+}
+
 /* Write information about registers and basic blocks into FILE.  The
    bitmap is in the form used by df_byte_lr.  This is part of making a
    debugging dump.  */

=== modified file 'gcc/df-problems.c'
--- gcc/df-problems.c   2011-05-04 20:24:15 +0000
+++ gcc/df-problems.c   2011-07-25 13:58:58 +0000
@@ -432,6 +432,7 @@ df_rd_local_compute (bitmap all_blocks)
 {
   unsigned int bb_index;
   bitmap_iterator bi;
+  hard_reg_set_iterator iter;
   unsigned int regno;
   struct df_rd_problem_data *problem_data
     = (struct df_rd_problem_data *) df_rd->problem_data;
@@ -449,7 +450,7 @@ df_rd_local_compute (bitmap all_blocks)
     }
 
   /* Set up the knockout bit vectors to be applied across EH_EDGES.  */
-  EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, regno, bi)
+  EXECUTE_IF_SET_IN_HARD_REG_SET (regs_invalidated_by_call, 0, regno, iter)
     {
       if (DF_DEFS_COUNT (regno) > DF_SPARSE_THRESHOLD)
        bitmap_set_bit (sparse_invalidated, regno);
@@ -969,6 +970,29 @@ df_lr_confluence_0 (basic_block bb)
     bitmap_copy (op1, &df->hardware_regs_used);
 }
 
+/* to |= from1 & ~from2
+   from2 is of type HARD_REG_SET */
+
+static bool
+bitmap_ior_and_compl_from_hard_reg_set (bitmap to, const_bitmap from1,
+                                       HARD_REG_SET from2)
+{
+  bool ret;
+  unsigned int i;
+  bitmap_head from1_tmp;
+  hard_reg_set_iterator iter;
+
+  bitmap_initialize (&from1_tmp, &bitmap_default_obstack);
+  bitmap_copy (&from1_tmp, from1);
+
+  /* TODO optimise per-word */
+  EXECUTE_IF_SET_IN_HARD_REG_SET (from2, 0, i, iter)
+    bitmap_clear_bit (&from1_tmp, i);
+  ret = bitmap_ior_into (to, &from1_tmp);
+
+  bitmap_clear (&from1_tmp);
+  return ret;
+}
 
 /* Confluence function that ignores fake edges.  */
 
@@ -983,7 +1007,8 @@ df_lr_confluence_n (edge e)
   /* ??? Abnormal call edges ignored for the moment, as this gets
      confused by sibling call edges, which crashes reg-stack.  */
   if (e->flags & EDGE_EH)
-    changed = bitmap_ior_and_compl_into (op1, op2, 
regs_invalidated_by_call_regset);
+    changed = bitmap_ior_and_compl_from_hard_reg_set (op1, op2,
+                                                     regs_invalidated_by_call);
   else
     changed = bitmap_ior_into (op1, op2);
 
@@ -4450,8 +4475,8 @@ df_md_confluence_n (edge e)
     return false;
 
   if (e->flags & EDGE_EH)
-    return bitmap_ior_and_compl_into (op1, op2,
-                                     regs_invalidated_by_call_regset);
+    return bitmap_ior_and_compl_from_hard_reg_set (op1, op2,
+                                                  regs_invalidated_by_call);
   else
     return bitmap_ior_into (op1, op2);
 }

=== modified file 'gcc/df-scan.c'
--- gcc/df-scan.c       2011-02-02 20:08:06 +0000
+++ gcc/df-scan.c       2011-07-25 13:58:58 +0000
@@ -409,7 +409,7 @@ df_scan_start_dump (FILE *file ATTRIBUTE
   rtx insn;
 
   fprintf (file, ";;  invalidated by call \t");
-  df_print_regset (file, regs_invalidated_by_call_regset);
+  df_print_hard_reg_set (file, regs_invalidated_by_call);
   fprintf (file, ";;  hardware regs used \t");
   df_print_regset (file, &df->hardware_regs_used);
   fprintf (file, ";;  regular block artificial uses \t");
@@ -3317,7 +3317,7 @@ df_get_call_refs (struct df_collection_r
                   int flags)
 {
   rtx note;
-  bitmap_iterator bi;
+  hard_reg_set_iterator iter;
   unsigned int ui;
   bool is_sibling_call;
   unsigned int i;
@@ -3375,7 +3375,7 @@ df_get_call_refs (struct df_collection_r
        }
 
   is_sibling_call = SIBLING_CALL_P (insn_info->insn);
-  EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, ui, bi)
+  EXECUTE_IF_SET_IN_HARD_REG_SET (regs_invalidated_by_call, 0, ui, iter)
     {
       if (!global_regs[ui]
          && (!bitmap_bit_p (&defs_generated, ui))

=== modified file 'gcc/df.h'
--- gcc/df.h    2010-12-14 00:23:40 +0000
+++ gcc/df.h    2011-07-25 13:58:58 +0000
@@ -912,6 +912,7 @@ extern df_ref df_find_use (rtx, rtx);
 extern bool df_reg_used (rtx, rtx);
 extern void df_worklist_dataflow (struct dataflow *,bitmap, int *, int);
 extern void df_print_regset (FILE *file, bitmap r);
+extern void df_print_hard_reg_set (FILE *f, HARD_REG_SET r);
 extern void df_print_word_regset (FILE *file, bitmap r);
 extern void df_dump (FILE *);
 extern void df_dump_region (FILE *);

=== modified file 'gcc/reginfo.c'
--- gcc/reginfo.c       2011-05-01 12:33:13 +0000
+++ gcc/reginfo.c       2011-07-25 13:23:36 +0000
@@ -87,10 +87,6 @@ static const char initial_call_really_us
    and are also considered fixed.  */
 char global_regs[FIRST_PSEUDO_REGISTER];
 
-/* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used
-   in dataflow more conveniently.  */
-regset regs_invalidated_by_call_regset;
-
 /* The bitmap_obstack is used to hold some static variables that
    should not be reset after each function is compiled.  */
 static bitmap_obstack persistent_obstack;
@@ -441,13 +437,6 @@ init_reg_sets_1 (void)
   CLEAR_HARD_REG_SET (call_used_reg_set);
   CLEAR_HARD_REG_SET (call_fixed_reg_set);
   CLEAR_HARD_REG_SET (regs_invalidated_by_call);
-  if (!regs_invalidated_by_call_regset)
-    {
-      bitmap_obstack_initialize (&persistent_obstack);
-      regs_invalidated_by_call_regset = ALLOC_REG_SET (&persistent_obstack);
-    }
-  else
-    CLEAR_REG_SET (regs_invalidated_by_call_regset);
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     {
@@ -477,10 +466,7 @@ init_reg_sets_1 (void)
       if (i == STACK_POINTER_REGNUM)
        ;
       else if (global_regs[i])
-        {
          SET_HARD_REG_BIT (regs_invalidated_by_call, i);
-         SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i);
-       }
       else if (i == FRAME_POINTER_REGNUM)
        ;
 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
@@ -495,10 +481,7 @@ init_reg_sets_1 (void)
               && i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i])
        ;
       else if (CALL_REALLY_USED_REGNO_P (i))
-        {
          SET_HARD_REG_BIT (regs_invalidated_by_call, i);
-         SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i);
-        }
     }
 
   COPY_HARD_REG_SET(call_fixed_reg_set, fixed_reg_set);
@@ -853,10 +836,7 @@ globalize_reg (int i)
      appropriate regs_invalidated_by_call bit, even if it's already
      set in fixed_regs.  */
   if (i != STACK_POINTER_REGNUM)
-    {
       SET_HARD_REG_BIT (regs_invalidated_by_call, i);
-      SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i);
-    }
 
   /* If already fixed, nothing else to do.  */
   if (fixed_regs[i])

=== modified file 'gcc/regset.h'
--- gcc/regset.h        2010-05-22 21:24:53 +0000
+++ gcc/regset.h        2011-07-25 13:23:36 +0000
@@ -110,11 +110,6 @@ typedef bitmap_iterator reg_set_iterator
 #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
   EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI)        \
 
-/* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used
-   in dataflow more conveniently.  */
-
-extern regset regs_invalidated_by_call_regset;
-
 /* An obstack for regsets.  */
 extern bitmap_obstack reg_obstack;
 

Reply via email to