2008-12-18 Kenneth Zadeck <zadeck@naturalbridge.com>
authorzadeck <zadeck@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Dec 2008 13:38:39 +0000 (13:38 +0000)
committerzadeck <zadeck@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Dec 2008 13:38:39 +0000 (13:38 +0000)
PR rtl-optimization/37922
* dse.c (bb_info): Added regs_live field.
(look_for_hardregs): New function.
(replace_read): Added regs_live parameter and code to check that
shift sequence does not clobber live hardregs.
(check_mem_read_rtx): Added parameter to replace_read.
(dse_step1): Added regs_live bitmap and initialize it.
(rest_of_handle_dse): Added DF_NOTES problem and earlier call to
df_analyze.
* df-problems.c Renamed to
df_simulate_initialize_backwards.
(df_simulate_one_insn): Renamed to
df_simulate_one_insn_backwards.
(df_simulate_artificial_refs_at_top): Renamed to
df_simulate_finalize_backwards.
(df_simulate_initialized_forwards,
df_simulate_one_insn_forwards,
df_simulate_finalize_backwards): New functions.
* df.h (df_simulate_artificial_refs_at_end): Renamed to
df_simulate_initialize_backwards.
(df_simulate_one_insn): Renamed to
df_simulate_one_insn_backwards.
(df_simulate_artificial_refs_at_top): Renamed to
df_simulate_finalize_backwards.
(df_simulate_initialized_forwards,
df_simulate_one_insn_forwards,
df_simulate_finalize_backwards): New functions.
* ra-conflict.c (global_conflicts): Renamed
df_simulate_artificial_refs_at_end to
df_simulate_initialize_backwards.
* sel-sched.c (propagate_lv_set): Renamed df_simulate_one_insn to
df_simulate_one_insn_backwards.
* ifcvt.c (dead_or_predicable): Renamed
df_simulate_artificial_refs_at_end to
df_simulate_initialize_backwards. Renamed df_simulate_one_insn to
df_simulate_one_insn_backwards.
* recog.c (peephole2_optimize): Ditto.
* rtl-factoring (collect_pattern_seqs, clear_regs_live_in_seq): Ditto.

2008-12-18  Kenneth Zadeck <zadeck@naturalbridge.com>

PR rtl-optimization/37922
* g++.dg/torture/pr37922.C: New test.

git-svn-id: svn://gcc.gnu.org/svn/gcc/trunk@142809 138bc75d-0d04-0410-961f-82ee72b054a4

12 files changed:
gcc/ChangeLog
gcc/dce.c
gcc/df-problems.c
gcc/df.h
gcc/dse.c
gcc/ifcvt.c
gcc/ra-conflict.c
gcc/recog.c
gcc/rtl-factoring.c
gcc/sel-sched.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr37922.C [new file with mode: 0644]

index a76282c..7862b10 100644 (file)
@@ -1,3 +1,44 @@
+2008-12-18  Kenneth Zadeck <zadeck@naturalbridge.com>
+
+       PR rtl-optimization/37922
+       * dse.c (bb_info): Added regs_live field.
+       (look_for_hardregs): New function.
+       (replace_read): Added regs_live parameter and code to check that
+       shift sequence does not clobber live hardregs.
+       (check_mem_read_rtx): Added parameter to replace_read.
+       (dse_step1): Added regs_live bitmap and initialize it.
+       (rest_of_handle_dse): Added DF_NOTES problem and earlier call to
+       df_analyze.
+       * df-problems.c Renamed to 
+       df_simulate_initialize_backwards.
+       (df_simulate_one_insn): Renamed to
+       df_simulate_one_insn_backwards.
+       (df_simulate_artificial_refs_at_top): Renamed to 
+       df_simulate_finalize_backwards.
+       (df_simulate_initialized_forwards,
+       df_simulate_one_insn_forwards,
+       df_simulate_finalize_backwards): New functions.
+       * df.h (df_simulate_artificial_refs_at_end): Renamed to 
+       df_simulate_initialize_backwards.
+       (df_simulate_one_insn): Renamed to
+       df_simulate_one_insn_backwards.
+       (df_simulate_artificial_refs_at_top): Renamed to 
+       df_simulate_finalize_backwards.
+       (df_simulate_initialized_forwards,
+       df_simulate_one_insn_forwards,
+       df_simulate_finalize_backwards): New functions.
+       * ra-conflict.c (global_conflicts): Renamed
+       df_simulate_artificial_refs_at_end to
+       df_simulate_initialize_backwards.
+       * sel-sched.c (propagate_lv_set): Renamed df_simulate_one_insn to
+       df_simulate_one_insn_backwards.
+       * ifcvt.c (dead_or_predicable): Renamed
+       df_simulate_artificial_refs_at_end to
+       df_simulate_initialize_backwards. Renamed df_simulate_one_insn to
+       df_simulate_one_insn_backwards.
+       * recog.c (peephole2_optimize): Ditto.
+       * rtl-factoring (collect_pattern_seqs, clear_regs_live_in_seq): Ditto.
+
 2008-12-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/38533
index 63ea380..1adea75 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -607,7 +607,7 @@ dce_process_block (basic_block bb, bool redo_out, bitmap au)
 
   bitmap_copy (local_live, DF_LR_OUT (bb));
 
-  df_simulate_artificial_refs_at_end (bb, local_live);
+  df_simulate_initialize_backwards (bb, local_live);
 
   FOR_BB_INSNS_REVERSE (bb, insn)
     if (INSN_P (insn))
@@ -636,7 +636,7 @@ dce_process_block (basic_block bb, bool redo_out, bitmap au)
          df_simulate_uses (insn, local_live);
       }
   
-  df_simulate_artificial_refs_at_top (bb, local_live);
+  df_simulate_finalize_backwards (bb, local_live);
 
   block_changed = !bitmap_equal_p (local_live, DF_LR_IN (bb));
   if (block_changed)
index 25dea30..829698b 100644 (file)
@@ -3759,24 +3759,19 @@ df_simulate_fixup_sets (basic_block bb, bitmap live)
    The following three functions are used only for BACKWARDS scanning:
    i.e. they process the defs before the uses.
 
-   df_simulate_artificial_refs_at_end should be called first with a
+   df_simulate_initialize_backwards should be called first with a
    bitvector copyied from the DF_LIVE_OUT or DF_LR_OUT.  Then
-   df_simulate_one_insn should be called for each insn in the block,
-   starting with the last on.  Finally,
-   df_simulate_artificial_refs_at_top can be called to get a new value
+   df_simulate_one_insn_backwards should be called for each insn in
+   the block, starting with the last on.  Finally,
+   df_simulate_finalize_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 not be difficult to define a similar set of functions
-   that work in the forwards direction.  In that case the functions
-   would ignore the use sets and look for the REG_DEAD and REG_UNUSED
-   notes.
-----------------------------------------------------------------------------*/
+   ----------------------------------------------------------------------------*/
 
 /* Apply the artificial uses and defs at the end of BB in a backwards
    direction.  */
 
 void 
-df_simulate_artificial_refs_at_end (basic_block bb, bitmap live)
+df_simulate_initialize_backwards (basic_block bb, bitmap live)
 {
   df_ref *def_rec;
   df_ref *use_rec;
@@ -3801,7 +3796,7 @@ df_simulate_artificial_refs_at_end (basic_block bb, bitmap live)
 /* Simulate the backwards effects of INSN on the bitmap LIVE.  */
 
 void 
-df_simulate_one_insn (basic_block bb, rtx insn, bitmap live)
+df_simulate_one_insn_backwards (basic_block bb, rtx insn, bitmap live)
 {
   if (! INSN_P (insn))
     return;    
@@ -3816,7 +3811,7 @@ df_simulate_one_insn (basic_block bb, rtx insn, bitmap live)
    direction.  */
 
 void 
-df_simulate_artificial_refs_at_top (basic_block bb, bitmap live)
+df_simulate_finalize_backwards (basic_block bb, bitmap live)
 {
   df_ref *def_rec;
 #ifdef EH_USES
@@ -3840,3 +3835,92 @@ df_simulate_artificial_refs_at_top (basic_block bb, bitmap live)
     }
 #endif
 }
+/*----------------------------------------------------------------------------
+   The following three functions are used only for FORWARDS scanning:
+   i.e. they process the defs and the REG_DEAD and REG_UNUSED notes.
+   Thus it is important to add the DF_NOTES problem to the stack of 
+   problems computed before using these functions.
+
+   df_simulate_initialize_forwards should be called first with a
+   bitvector copyied from the DF_LIVE_IN or DF_LR_IN.  Then
+   df_simulate_one_insn_forwards should be called for each insn in
+   the block, starting with the last on.  Finally,
+   df_simulate_finalize_forwards can be called to get a new value
+   of the sets at the bottom of the block (this is rarely used).
+   ----------------------------------------------------------------------------*/
+
+/* Apply the artificial uses and defs at the top of BB in a backwards
+   direction.  */
+
+void 
+df_simulate_initialize_forwards (basic_block bb, bitmap live)
+{
+  df_ref *def_rec;
+  int bb_index = bb->index;
+  
+  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)
+       bitmap_clear_bit (live, DF_REF_REGNO (def));
+    }
+}
+
+/* Simulate the backwards effects of INSN on the bitmap LIVE.  */
+
+void 
+df_simulate_one_insn_forwards (basic_block bb, rtx insn, bitmap live)
+{
+  rtx link;
+  if (! INSN_P (insn))
+    return;    
+
+  /* Make sure that the DF_NOTES really is an active df problem.  */ 
+  gcc_assert (df_note);
+
+  df_simulate_defs (insn, live);
+
+  /* Clear all of the registers that go dead.  */
+  for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
+    {
+      switch (REG_NOTE_KIND (link))
+       case REG_DEAD:
+       case REG_UNUSED:
+       {
+         rtx reg = XEXP (link, 0);
+         int regno = REGNO (reg);
+         if (regno < FIRST_PSEUDO_REGISTER)
+           {
+             int n = hard_regno_nregs[regno][GET_MODE (reg)];
+             while (--n >= 0)
+               bitmap_clear_bit (live, regno + n);
+           }
+         else 
+           bitmap_clear_bit (live, regno);
+         break;
+       default:
+         break;
+       }
+    }
+  df_simulate_fixup_sets (bb, live);
+}
+
+
+/* Apply the artificial uses and defs at the end of BB in a backwards
+   direction.  */
+
+void 
+df_simulate_finalize_forwards (basic_block bb, bitmap live)
+{
+  df_ref *def_rec;
+  int bb_index = bb->index;
+  
+  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) == 0)
+       bitmap_clear_bit (live, DF_REF_REGNO (def));
+    }
+}
+
+
index 979065a..5cd5dfc 100644 (file)
--- a/gcc/df.h
+++ b/gcc/df.h
@@ -959,9 +959,12 @@ 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_end (basic_block, bitmap);
-extern void df_simulate_one_insn (basic_block, rtx, bitmap);
-extern void df_simulate_artificial_refs_at_top (basic_block, bitmap);
+extern void df_simulate_initialize_backwards (basic_block, bitmap);
+extern void df_simulate_one_insn_backwards (basic_block, rtx, bitmap);
+extern void df_simulate_finalize_backwards (basic_block, bitmap);
+extern void df_simulate_initialize_forwards (basic_block, bitmap);
+extern void df_simulate_one_insn_forwards (basic_block, rtx, bitmap);
+extern void df_simulate_finalize_forwards (basic_block, bitmap);
 
 /* Functions defined in df-scan.c.  */
 
diff --cc gcc/dse.c
Simple merge
diff --cc gcc/ifcvt.c
Simple merge
Simple merge
diff --cc gcc/recog.c
Simple merge
Simple merge
diff --cc gcc/sel-sched.c
Simple merge
Simple merge