[patch] for PR 28839

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Thu Aug 31 18:29:00 GMT 2006


Hello,

this is a bug in prune_unused_phi_nodes function that I have recently
rewritten: in case there is a definition in the same block as the
argument of a phi node, we will ignore this definition, which may cause
us to believe that unnecessary phi nodes are needed (because we believe
that they must feed this argument).  For virtual ssa names, this
creates overlapping life ranges and may lead to ice (in optimizers that are
run before the next dce pass, that removes such unnecessary phi nodes).

Bootstrapped & regtested on i686 and x86_64.

Zdenek

	PR tree-optimization/28839
	* tree-into-ssa.c (prune_unused_phi_nodes): Take into account kills in
	blocks in that phi arguments appear.

	* gcc.dg/pr28839.c: New test.

Index: tree-into-ssa.c
===================================================================
*** tree-into-ssa.c	(revision 116600)
--- tree-into-ssa.c	(working copy)
*************** prune_unused_phi_nodes (bitmap phis, bit
*** 977,982 ****
--- 977,989 ----
  	  if (bitmap_bit_p (uses, u))
  	    continue;
  
+ 	  /* In case there is a kill directly in the use block, do not record
+ 	     the use (this is also necessary for correctness, as we assume that
+ 	     uses dominated by a def directly in their block have been filtered
+ 	     out before).  */
+ 	  if (bitmap_bit_p (kills, u))
+ 	    continue;
+ 
  	  bitmap_set_bit (uses, u);
  	  VEC_safe_push (int, heap, worklist, u);
  	}
Index: testsuite/gcc.dg/pr28839.c
===================================================================
*** testsuite/gcc.dg/pr28839.c	(revision 0)
--- testsuite/gcc.dg/pr28839.c	(revision 0)
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+ /* { dg-options "-O2 -msse2 -ftree-vectorize -funswitch-loops" } */
+ 
+ static int ready[10];
+ void abort (void);
+ void test_once (int t,int t1)
+ {
+   int i, repeat;
+   for (i = 0; i < 10; i++)
+     {
+       ready[i] = 0;
+       if (t1)
+ 	if (b())
+ 	  abort ();
+     }
+   if (t)
+     abort ();
+ }



More information about the Gcc-patches mailing list