public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix DCE for GVN-PRE
@ 2004-06-11  3:27 Steven Bosscher
  2004-06-11  4:03 ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Bosscher @ 2004-06-11  3:27 UTC (permalink / raw)
  To: gcc-patches

Hi,

The following fixes an ICE in tree-ssa-dce.c, where we try
to make the successor of the entry block control dependent
on the entry block.

This shows up as an ICE in gcc.c-torture/compile/950613-1.c,
but for some reason only with the GVN-PRE patch applied.

Bootstrapped and regtested on x86_64-unknown-linux-gnu, OK?

Gr.
Steven

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

Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v
retrieving revision 1.1.2.84
diff -c -3 -p -r1.1.2.84 tree-ssa-dce.c
*** tree-ssa-dce.c      23 Mar 2004 08:28:22 -0000      1.1.2.84
--- tree-ssa-dce.c      29 Mar 2004 10:59:17 -0000
*************** mark_control_dependent_edges_necessary (
*** 470,475 ****
--- 470,483 ----
  {
    int edge_number;

+ #ifdef ENABLE_CHECKING
+   if (bb == EXIT_BLOCK_PTR)
+     abort ();
+ #endif
+
+   if (bb == ENTRY_BLOCK_PTR)
+     return;
+
    EXECUTE_IF_CONTROL_DEPENDENT (bb->index, edge_number,
      {
        tree t;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix DCE for GVN-PRE
  2004-06-11  3:27 Fix DCE for GVN-PRE Steven Bosscher
@ 2004-06-11  4:03 ` Diego Novillo
  2004-06-11 18:18   ` Daniel Berlin
  0 siblings, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2004-06-11  4:03 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: gcc-patches

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?


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix DCE for GVN-PRE
  2004-06-11  4:03 ` Diego Novillo
@ 2004-06-11 18:18   ` Daniel Berlin
  2004-06-11 20:27     ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Berlin @ 2004-06-11 18:18 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-patches, Steven Bosscher


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.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix DCE for GVN-PRE
  2004-06-11 18:18   ` Daniel Berlin
@ 2004-06-11 20:27     ` Diego Novillo
  0 siblings, 0 replies; 4+ messages in thread
From: Diego Novillo @ 2004-06-11 20:27 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: gcc-patches, Steven Bosscher

On Fri, 2004-06-11 at 12:43, Daniel Berlin wrote:

> 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.
> 
Ah, thanks.  The patch is OK then.


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-06-11 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-11  3:27 Fix DCE for GVN-PRE Steven Bosscher
2004-06-11  4:03 ` Diego Novillo
2004-06-11 18:18   ` Daniel Berlin
2004-06-11 20:27     ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).