aboutsummaryrefslogtreecommitdiff
path: root/gcc/ssa-dce.c
diff options
context:
space:
mode:
authorJeffrey A Law <law@cygnus.com>2001-06-28 18:24:55 +0000
committerJeff Law <law@gcc.gnu.org>2001-06-28 12:24:55 -0600
commitfa2eec9a67a5134065176babcaddf3867fe47920 (patch)
tree82ecd03ca4c9f05046ceb72b92b971adedbbe29c /gcc/ssa-dce.c
parent7a442791bbd35236ae2c45e383db88d704f8f41c (diff)
downloadgcc-fa2eec9a67a5134065176babcaddf3867fe47920.zip
gcc-fa2eec9a67a5134065176babcaddf3867fe47920.tar.gz
gcc-fa2eec9a67a5134065176babcaddf3867fe47920.tar.bz2
ssa-dce.c (eliminate_dead_code): Properly handle control dependencies implied by PHI nodes.
* ssa-dce.c (eliminate_dead_code): Properly handle control dependencies implied by PHI nodes. From-SVN: r43643
Diffstat (limited to 'gcc/ssa-dce.c')
-rw-r--r--gcc/ssa-dce.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/ssa-dce.c b/gcc/ssa-dce.c
index 1629803..4ccd9e0 100644
--- a/gcc/ssa-dce.c
+++ b/gcc/ssa-dce.c
@@ -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);
+ }
+ });
+
+ }
+ }
}
}