Re: [PATCH 2/6] FOR_EACH_ARTIFICIAL_{DEF,USE}

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:44 PM, Richard Sandiford wrote:
> gcc/
> * df.h (FOR_EACH_ARTIFICIAL_USE, FOR_EACH_ARTIFICIAL_DEF): New macros.
> * cse.c (cse_extended_basic_block): Use them.
> * dce.c (mark_artificial_use): Likewise.
> * df-problems.c (df_rd_simulate_artificial_defs_at_top): Likewise.
> (df_lr_bb_local_compute, df_live_bb_local_compute): Likewise.
> (df_chain_remove_problem, df_chain_bb_dump): Likewise.
> (df_word_lr_bb_local_compute, df_note_bb_compute): Likewise.
> (df_simulate_initialize_backwards): Likewise.
> (df_simulate_finalize_backwards): Likewise.
> (df_simulate_initialize_forwards): Likewise.
> (df_md_simulate_artificial_defs_at_top): Likewise.
> * df-scan.c (df_reorganize_refs_by_reg_by_insn): Likewise.
> * regrename.c (init_rename_info): Likewise.
> * regstat.c (regstat_bb_compute_ri): Likewise.
> (regstat_bb_compute_calls_crossed): Likewise.

OK.

Ciao!
Steven


[PATCH 2/6] FOR_EACH_ARTIFICIAL_{DEF,USE}

2014-06-14 Thread Richard Sandiford
Similar to patch 1, but for artificial uses and defs.

Richard


gcc/
* df.h (FOR_EACH_ARTIFICIAL_USE, FOR_EACH_ARTIFICIAL_DEF): New macros.
* cse.c (cse_extended_basic_block): Use them.
* dce.c (mark_artificial_use): Likewise.
* df-problems.c (df_rd_simulate_artificial_defs_at_top): Likewise.
(df_lr_bb_local_compute, df_live_bb_local_compute): Likewise.
(df_chain_remove_problem, df_chain_bb_dump): Likewise.
(df_word_lr_bb_local_compute, df_note_bb_compute): Likewise.
(df_simulate_initialize_backwards): Likewise.
(df_simulate_finalize_backwards): Likewise.
(df_simulate_initialize_forwards): Likewise.
(df_md_simulate_artificial_defs_at_top): Likewise.
* df-scan.c (df_reorganize_refs_by_reg_by_insn): Likewise.
* regrename.c (init_rename_info): Likewise.
* regstat.c (regstat_bb_compute_ri): Likewise.
(regstat_bb_compute_calls_crossed): Likewise.

Index: gcc/df.h
===
--- gcc/df.h2014-06-14 19:40:28.450704775 +0100
+++ gcc/df.h2014-06-14 20:01:12.353400410 +0100
@@ -775,6 +775,14 @@ #define FOR_EACH_INSN_USE(ITER, INSN) \
 #define FOR_EACH_INSN_EQ_USE(ITER, INSN) \
   FOR_EACH_INSN_INFO_EQ_USE(ITER, DF_INSN_INFO_GET (INSN))
 
+#define FOR_EACH_ARTIFICIAL_USE(ITER, BB_INDEX) \
+  for (df_ref *ITER##_ = df_get_artificial_uses (BB_INDEX); \
+   (ITER = *ITER##_); ++ITER##_)
+
+#define FOR_EACH_ARTIFICIAL_DEF(ITER, BB_INDEX) \
+  for (df_ref *ITER##_ = df_get_artificial_defs (BB_INDEX); \
+   (ITER = *ITER##_); ++ITER##_)
+
 /* An obstack for bitmap not related to specific dataflow problems.
This obstack should e.g. be used for bitmaps with a short life time
such as temporary bitmaps.  This obstack is declared in df-core.c.  */
Index: gcc/cse.c
===
--- gcc/cse.c   2014-06-14 19:40:26.919671918 +0100
+++ gcc/cse.c   2014-06-14 20:01:12.351400390 +0100
@@ -6406,14 +6406,11 @@ cse_extended_basic_block (struct cse_bas
 edge pointing to that bb.  */
   if (bb_has_eh_pred (bb))
{
- df_ref *def_rec;
+ df_ref def;
 
- for (def_rec = df_get_artificial_defs (bb->index); *def_rec; 
def_rec++)
-   {
- df_ref def = *def_rec;
- if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
-   invalidate (DF_REF_REG (def), GET_MODE (DF_REF_REG (def)));
-   }
+ FOR_EACH_ARTIFICIAL_DEF (def, bb->index)
+   if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
+ invalidate (DF_REF_REG (def), GET_MODE (DF_REF_REG (def)));
}
 
   optimize_this_for_speed_p = optimize_bb_for_speed_p (bb);
Index: gcc/dce.c
===
--- gcc/dce.c   2014-06-14 19:40:44.451212858 +0100
+++ gcc/dce.c   2014-06-14 20:01:23.401510789 +0100
@@ -661,16 +661,13 @@ mark_artificial_uses (void)
 {
   basic_block bb;
   struct df_link *defs;
-  df_ref *use_rec;
+  df_ref use;
 
   FOR_ALL_BB_FN (bb, cfun)
-{
-  for (use_rec = df_get_artificial_uses (bb->index);
-  *use_rec; use_rec++)
-   for (defs = DF_REF_CHAIN (*use_rec); defs; defs = defs->next)
- if (! DF_REF_IS_ARTIFICIAL (defs->ref))
-   mark_insn (DF_REF_INSN (defs->ref), false);
-}
+FOR_EACH_ARTIFICIAL_USE (use, bb->index)
+  for (defs = DF_REF_CHAIN (use); defs; defs = defs->next)
+   if (!DF_REF_IS_ARTIFICIAL (defs->ref))
+ mark_insn (DF_REF_INSN (defs->ref), false);
 }
 
 
Index: gcc/df-problems.c
===
--- gcc/df-problems.c   2014-06-14 19:47:23.317957520 +0100
+++ gcc/df-problems.c   2014-06-14 20:01:12.352400400 +0100
@@ -245,20 +245,17 @@ df_rd_alloc (bitmap all_blocks)
 df_rd_simulate_artificial_defs_at_top (basic_block bb, bitmap local_rd)
 {
   int bb_index = bb->index;
-  df_ref *def_rec;
-  for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
-{
-  df_ref def = *def_rec;
-  if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
-   {
- unsigned int dregno = DF_REF_REGNO (def);
- if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
-   bitmap_clear_range (local_rd,
-   DF_DEFS_BEGIN (dregno),
-   DF_DEFS_COUNT (dregno));
- bitmap_set_bit (local_rd, DF_REF_ID (def));
-   }
-}
+  df_ref def;
+  FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
+if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
+  {
+   unsigned int dregno = DF_REF_REGNO (def);
+   if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
+ bitmap_clear_range (local_rd,
+ DF_DEFS_BEGIN (dregno),
+ DF_DEFS_COUNT (dregno));
+   bitmap_set_bit (local_rd, DF_REF_ID (def));
+  }
 }
 
 /* Add th