This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
SSA DCE bugfix
- To: gcc-patches at gcc dot gnu dot org
- Subject: SSA DCE bugfix
- From: law at redhat dot com
- Date: Thu, 28 Jun 2001 11:16:34 -0700
- Reply-to: law at redhat dot com
This patch fixes the bug in SSA DCE that's been recently discussed on the
main development list.
I've bootstrapped this on a private tree with SSA enabled by default on
ia64-linux.
This was a bug exposed by c-torture when using SSA opts on a different
target. I don't recall precisely what test it was. Regardless, we don't
need to add a new testcase to the testsuite for this bug.
* ssa-dce.c (eliminate_dead_code): Properly handle control
dependencies implied by PHI nodes.
Index: ssa-dce.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ssa-dce.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 ssa-dce.c
*** ssa-dce.c 2001/06/28 17:18:36 1.2
--- ssa-dce.c 2001/06/28 17:54:25
*************** eliminate_dead_code ()
*** 558,563 ****
--- 558,598 ----
&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);
+ }
+ });
+
+ }
+ }
}
}