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]

Re: Fix DCE for GVN-PRE



On Jun 10, 2004, at 8:09 PM, Diego Novillo wrote:


On Thu, 2004-06-10 at 19:47, Steven Bosscher wrote:

	* tree-ssa-dce.c (mark_control_dependent_edges_necessary):
	Don't try to mark anything control dependent on the entry or
	exit blocks.

Hmm, why did we think that the successor of ENTRY is control dependent
on ENTRY?  After all, it does postdominate ENTRY.  Aren't you papering
over a bug in the computation of control depenencies?


No, it's not a control dependence problem.


What happens is that we follow the phi arg edges, and we have phis with an alternative coming from the entry block, because the CFG looks like this:

  # BLOCK 0
  # PRED: 1 (ab) ENTRY (fallthru)
...

Because block 0 has multiple predecessors, we have a phi in block 0 with an argument from ENTRY, and an argument from block 1, like so:
# TMT.7<D1128>_20 = PHI <TMT.7<D1128>_22(-1), TMT.7<D1128>_21(1)>;
# TMT.6<D1127>_19 = PHI <TMT.6<D1127>_23(-1), TMT.6<D1127>_24(1)>;
# pc<D1102>_1 = PHI <pc<D1102>_4(-1), pc<D1102>_2(1)>;


we try to mark the edges coming from the phi as control dependent, which ends up accessing member -1 of an array, which blows up miserably.

This used to work because old PRE used to force split critical edges from the entry block:

  if (ENTRY_BLOCK_PTR->succ->dest->pred->pred_next)
    if (!(ENTRY_BLOCK_PTR->succ->flags & EDGE_ABNORMAL))
      split_edge (ENTRY_BLOCK_PTR->succ);

So by the time we got to CD-DCE, the phi arg edge led to newly created block 3 (which had a predecessor of -1), instead of block -1.

GVN-PRE doesn't do this because it doesn't have to.


You can see this failure if you turn off old PRE (IE compile 950613-1.c with -fno-tree-pre). It'll segfault.




Diego.




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