This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[trunk] patch to clean up simulation of insns in df.


This patch is a replacement for the df part of the patch for which Julian Brown is waiting for a review on the arm part. The problem that he discovered on the arm was that for exception blocks, the artificial uses at the top and the artificial defs at the top are not disjoint sets. Thus the order that you process the uses and defs does make a difference on the arm.

Julian's patch was really a stop gap effort. The patch here cleans things up properly. I renamed df_simulate_artificial_refs_at_end to df_simulate_artificial_refs_at_end_backwards and renamed df_simulate_artificial_refs_at_top to df_simulate_artificial_refs_at_top_backwards. I now process the defs first and uses second in df_simulate_artificial_refs_at_top_backwards. This provides a consistent set of calls for backwards scanning.

I removed df_simulate_one_insn_forwards since this was unused. It can be added back (as well as adding an appropriate artificial refs at the top function) if these become necessary.

If this is approved before the other part of Julian's patch, i will ask Julian to remove the df part of his patch. If this patch is approved after Julian's, he can commit his full patch and I will fixup this patch.

Tested on x86-{64,32}.

Ok?

Kenny

2008-05-15 Kenneth Zadeck <zadeck@naturalbridge.com>

   * ra-conflict.c (global_conflicts): Rename
   df_simulate_artificial_refs_at_end to
   df_simulate_artificial_refs_at_end_backwards.
   * ifcvt.c (dead_or_predicable): Ditto.
   * recog.c (peephole2_optimize): Ditto.
   * rtl-factoring.c (collect_pattern_seqs, clear_regs_live_in_seq):
   Ditto.
   * dce.c (dce_process_block): Ditto and rename
   df_simulate_artificial_refs_at_top to
   df_simulate_artificial_refs_at_top_backwards.
   * df.h: Rename
   df_simulate_artificial_refs_at_end to
   df_simulate_artificial_refs_at_end_backwards and rename
   df_simulate_artificial_refs_at_top to
   df_simulate_artificial_refs_at_top_backwards and delete
   df_simulate_one_insn_forwards.
   * df-problems.c (df_simulate_artificial_refs_at_end)
   Renamed to df_simulate_artificial_refs_at_end_backwards.
   (df_simulate_artificial_refs_at_top)
   Renamed to df_simulate_artificial_refs_at_top_backwards and
   reversed scanning of defs and uses.
   (df_simulate_one_insn_forwards): Removed.



Index: ra-conflict.c
===================================================================
--- ra-conflict.c	(revision 135302)
+++ ra-conflict.c	(working copy)
@@ -774,7 +774,7 @@ global_conflicts (void)
       bitmap_iterator bi;
 
       bitmap_copy (live, DF_LIVE_OUT (bb));
-      df_simulate_artificial_refs_at_end (bb, live);
+      df_simulate_artificial_refs_at_end_backwards (bb, live);
 
       sparseset_clear (allocnos_live);
       memset (live_subregs_used, 0, max_allocno * sizeof (int));
Index: ifcvt.c
===================================================================
--- ifcvt.c	(revision 135302)
+++ ifcvt.c	(working copy)
@@ -3907,7 +3907,7 @@ dead_or_predicable (basic_block test_bb,
       /* The loop below takes the set of live registers 
          after JUMP, and calculates the live set before EARLIEST. */
       bitmap_copy (test_live, df_get_live_in (other_bb));
-      df_simulate_artificial_refs_at_end (test_bb, test_live);
+      df_simulate_artificial_refs_at_end_backwards (test_bb, test_live);
       for (insn = jump; ; insn = prev)
 	{
 	  if (INSN_P (insn))
Index: recog.c
===================================================================
--- recog.c	(revision 135302)
+++ recog.c	(working copy)
@@ -2933,7 +2933,7 @@ peephole2_optimize (void)
 
       /* Start up propagation.  */
       bitmap_copy (live, DF_LR_OUT (bb));
-      df_simulate_artificial_refs_at_end (bb, live);
+      df_simulate_artificial_refs_at_end_backwards (bb, live);
       bitmap_copy (peep2_insn_data[MAX_INSNS_PER_PEEP2].live_before, live);
 
       for (insn = BB_END (bb); ; insn = prev)
Index: rtl-factoring.c
===================================================================
--- rtl-factoring.c	(revision 135302)
+++ rtl-factoring.c	(working copy)
@@ -464,7 +464,7 @@ collect_pattern_seqs (void)
     /* Initialize liveness propagation.  */
     INIT_REG_SET (&live);
     bitmap_copy (&live, DF_LR_OUT (bb));
-    df_simulate_artificial_refs_at_end (bb, &live);
+    df_simulate_artificial_refs_at_end_backwards (bb, &live);
 
     /* Propagate liveness info and mark insns where a stack reg is live.  */
     insn = BB_END (bb);
@@ -572,7 +572,7 @@ clear_regs_live_in_seq (HARD_REG_SET * r
   bb = BLOCK_FOR_INSN (insn);
   INIT_REG_SET (&live);
   bitmap_copy (&live, DF_LR_OUT (bb));
-  df_simulate_artificial_refs_at_end (bb, &live);
+  df_simulate_artificial_refs_at_end_backwards (bb, &live);
 
   /* Propagate until INSN if found.  */
   for (x = BB_END (bb); x != insn; x = PREV_INSN (x))
Index: dce.c
===================================================================
--- dce.c	(revision 135302)
+++ dce.c	(working copy)
@@ -756,7 +756,7 @@ dce_process_block (basic_block bb, bool 
 
   bitmap_copy (local_live, DF_LR_OUT (bb));
 
-  df_simulate_artificial_refs_at_end (bb, local_live);
+  df_simulate_artificial_refs_at_end_backwards (bb, local_live);
 
   FOR_BB_INSNS_REVERSE (bb, insn)
     if (INSN_P (insn))
@@ -785,7 +785,7 @@ dce_process_block (basic_block bb, bool 
 	  df_simulate_uses (insn, local_live);
       }
   
-  df_simulate_artificial_refs_at_top (bb, local_live);
+  df_simulate_artificial_refs_at_top_backwards (bb, local_live);
 
   block_changed = !bitmap_equal_p (local_live, DF_LR_IN (bb));
   if (block_changed)
Index: df.h
===================================================================
--- df.h	(revision 135302)
+++ df.h	(working copy)
@@ -913,10 +913,9 @@ extern void df_note_add_problem (void);
 extern void df_simulate_find_defs (rtx, bitmap);
 extern void df_simulate_defs (rtx, bitmap);
 extern void df_simulate_uses (rtx, bitmap);
-extern void df_simulate_artificial_refs_at_top (basic_block, bitmap);
-extern void df_simulate_one_insn_forwards (basic_block, rtx, bitmap);
-extern void df_simulate_artificial_refs_at_end (basic_block, bitmap);
+extern void df_simulate_artificial_refs_at_end_backwards (basic_block, bitmap);
 extern void df_simulate_one_insn_backwards (basic_block, rtx, bitmap);
+extern void df_simulate_artificial_refs_at_top_backwards (basic_block, bitmap);
 
 /* Functions defined in df-scan.c.  */
 
Index: df-problems.c
===================================================================
--- df-problems.c	(revision 135302)
+++ df-problems.c	(working copy)
@@ -3682,7 +3682,6 @@ df_note_add_problem (void)
    DF_LR_IN.  If you start at the bottom of the block use one of
    DF_LIVE_OUT or DF_LR_OUT.  BE SURE TO PASS A COPY OF THESE SETS,
    THEY WILL BE DESTROYED.
-
 ----------------------------------------------------------------------------*/
 
 
@@ -3757,87 +3756,87 @@ df_simulate_fixup_sets (basic_block bb, 
 }
 
 
-/* Apply the artificial uses and defs at the top of BB in a forwards
+/*----------------------------------------------------------------------------
+   The following three functions are used for backwards scanning:
+   i.e. they process the defs before the uses.
+
+   df_simulate_artificial_refs_at_end_backwards should be called first
+   with a bitvector copyied from the DF_LIVE_OUT or DF_LR_OUT.  Then
+   df_simulate_one_insn_backwards should be called for each insn in
+   the block, starting with the last on.  Finally, 
+   df_simulate_artificial_refs_at_top_backwards can be called to get a new 
+   value of the sets at the top of the block (this is rarely used).
+
+   It would be trivial to define a similar set of functions that work
+   in the forwards direction.  The only changes would be to process
+   the uses before the defs.  This has so far not been necessary.
+----------------------------------------------------------------------------*/
+
+/* Apply the artificial uses and defs at the end of BB in a backwards
    direction.  */
 
 void 
-df_simulate_artificial_refs_at_top (basic_block bb, bitmap live)
+df_simulate_artificial_refs_at_end_backwards (basic_block bb, bitmap live)
 {
   struct df_ref **def_rec;
-#ifdef EH_USES
   struct df_ref **use_rec;
-#endif
   int bb_index = bb->index;
   
-#ifdef EH_USES
-  for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
-    {
-      struct df_ref *use = *use_rec;
-      if (DF_REF_FLAGS (use) & DF_REF_AT_TOP)
-	bitmap_set_bit (live, DF_REF_REGNO (use));
-    }
-#endif
-
   for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
     {
       struct df_ref *def = *def_rec;
-      if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
+      if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
 	bitmap_clear_bit (live, DF_REF_REGNO (def));
     }
+
+  for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
+    {
+      struct df_ref *use = *use_rec;
+      if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
+	bitmap_set_bit (live, DF_REF_REGNO (use));
+    }
 }
 
 
-/* Simulate the forwards effects of INSN on the bitmap LIVE.  */
+/* Simulate the backwards effects of INSN on the bitmap LIVE.  */
 
 void 
-df_simulate_one_insn_forwards (basic_block bb, rtx insn, bitmap live)
+df_simulate_one_insn_backwards (basic_block bb, rtx insn, bitmap live)
 {
   if (! INSN_P (insn))
     return;	
   
-  df_simulate_uses (insn, live);
   df_simulate_defs (insn, live);
+  df_simulate_uses (insn, live);
   df_simulate_fixup_sets (bb, live);
 }
 
 
-/* Apply the artificial uses and defs at the end of BB in a backwards
+/* Apply the artificial uses and defs at the top of BB in a backwards
    direction.  */
 
 void 
-df_simulate_artificial_refs_at_end (basic_block bb, bitmap live)
+df_simulate_artificial_refs_at_top_backwards (basic_block bb, bitmap live)
 {
   struct df_ref **def_rec;
+#ifdef EH_USES
   struct df_ref **use_rec;
+#endif
   int bb_index = bb->index;
   
   for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
     {
       struct df_ref *def = *def_rec;
-      if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
+      if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
 	bitmap_clear_bit (live, DF_REF_REGNO (def));
     }
 
+#ifdef EH_USES
   for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
     {
       struct df_ref *use = *use_rec;
-      if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
+      if (DF_REF_FLAGS (use) & DF_REF_AT_TOP)
 	bitmap_set_bit (live, DF_REF_REGNO (use));
     }
+#endif
 }
-
-
-/* Simulate the backwards effects of INSN on the bitmap LIVE.  */
-
-void 
-df_simulate_one_insn_backwards (basic_block bb, rtx insn, bitmap live)
-{
-  if (! INSN_P (insn))
-    return;	
-  
-  df_simulate_defs (insn, live);
-  df_simulate_uses (insn, live);
-  df_simulate_fixup_sets (bb, live);
-}
-
-

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]