ssa-dce.c (eliminate_dead_code): Properly handle control dependencies implied by...
authorJeffrey A Law <law@cygnus.com>
Thu, 28 Jun 2001 18:24:55 +0000 (18:24 +0000)
committerJeff Law <law@gcc.gnu.org>
Thu, 28 Jun 2001 18:24:55 +0000 (12:24 -0600)
        * ssa-dce.c (eliminate_dead_code): Properly handle control
        dependencies implied by PHI nodes.

From-SVN: r43643

gcc/ChangeLog
gcc/ssa-dce.c

index a6f96b4f54eb2d933720de3437a1602e5fd0a1e7..5d363c361948e11b0c5fa5cbf3cae3f964e34d4f 100644 (file)
@@ -11,6 +11,9 @@ Thu Jun 28 20:13:11 CEST 2001  Jan Hubicka  <jh@suse.cz>
 
 Thu Jun 28 11:19:42 2001  Jeffrey A Law  (law@cygnus.com)
 
+       * ssa-dce.c (eliminate_dead_code): Properly handle control
+       dependencies implied by PHI nodes.
+
        * ssa-dce.c (eliminate_dead_code): Remove fake edges from the
        CFG after dead code elimination is complete.
 
index 1629803b8e8865cee4340e6dbe0d9851c932b0c4..4ccd9e01ccb263d4a7ed1ead31ff5c0afd4ce823 100644 (file)
@@ -558,6 +558,41 @@ eliminate_dead_code ()
                        &propagate_necessity_through_operand,
                        (PTR) &unprocessed_instructions);
 
+         /* PHI nodes are somewhat special in that each PHI alternative
+            has data and control dependencies.  The data dependencies
+            are handled via propagate_necessity_through_operand.  We
+            handle the control dependency here.
+
+            We consider the control dependent edges leading to the
+            predecessor block associated with each PHI alternative
+            as necessary.  */
+         if (PHI_NODE_P (current_instruction))
+           {
+             rtvec phi_vec = XVEC (SET_SRC (PATTERN (current_instruction)), 0);
+             int num_elem = GET_NUM_ELEM (phi_vec);
+             int v;
+
+             for (v = num_elem - 2; v >= 0; v -= 2)
+               {
+                 basic_block bb;
+
+                 bb = BASIC_BLOCK (INTVAL (RTVEC_ELT (phi_vec, v + 1)));
+                 EXECUTE_IF_CONTROL_DEPENDENT
+                   (cdbte, bb->end, edge_number,
+                   {
+                     rtx jump_insn;
+
+                     jump_insn = (INDEX_EDGE_PRED_BB (el, edge_number))->end;
+                     if (((GET_CODE (jump_insn) == JUMP_INSN))
+                         && UNNECESSARY_P (jump_insn))
+                       {
+                         RESURRECT_INSN (jump_insn);
+                         VARRAY_PUSH_RTX (unprocessed_instructions, jump_insn);
+                       }
+                   });
+
+               }
+           }
        }
     }