[Bug tree-optimization/21380] [4.0 Regression] ICE compiling with -O

Jeffrey A Law law@redhat.com
Fri May 6 03:03:00 GMT 2005


Basically we have a block which is marked as having threadable
edges.  However, due to other threading opportunities the block
in question has become unreachable.  We still attempt to thread
the (non-existent) incoming edges, leading to the segfault.

The fix is trivial.  If a block has become unreachable, there's
no sense in trying to thread through it.

Attached is the patch for the GCC 4.0 branch which has been bootstrapped
and regression tested on i686-pc-linux-gnu.  I'll be testing the same
patch for mainline overnight.


-------------- next part --------------
	PR tree-optimization/21380
	* tree-ssa-threadupdate.c (thread_through_all_blocks): Do not
	thread through a block with no preds.

 	* gcc.c-torture/compile/pr21380.c: New test.

Index: tree-ssa-threadupdate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-threadupdate.c,v
retrieving revision 2.20
diff -c -p -r2.20 tree-ssa-threadupdate.c
*** tree-ssa-threadupdate.c	27 Jan 2005 18:22:22 -0000	2.20
--- tree-ssa-threadupdate.c	6 May 2005 02:54:49 -0000
*************** thread_through_all_blocks (void)
*** 560,566 ****
  
    FOR_EACH_BB (bb)
      {
!       if (bb_ann (bb)->incoming_edge_threaded)
  	{
  	  thread_block (bb);
  	  retval = true;
--- 560,567 ----
  
    FOR_EACH_BB (bb)
      {
!       if (bb_ann (bb)->incoming_edge_threaded
! 	  && EDGE_COUNT (bb->preds) > 0)
  	{
  	  thread_block (bb);
  	  retval = true;

Index: testsuite/gcc.c-torture/compile/pr21380.c
===================================================================
RCS file: testsuite/gcc.c-torture/compile/pr21380.c
diff -N testsuite/gcc.c-torture/compile/pr21380.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.c-torture/compile/pr21380.c	6 May 2005 02:55:06 -0000
***************
*** 0 ****
--- 1,42 ----
+ void bar (void);
+                                                                                 
+ void
+ foo (int *diff)
+ {
+   double deltay = 0.0;
+   int Stangent = 0;
+   int mindiff;
+   int Sflipped = 0;
+   int i;
+   int Sturn, Snofit;
+                                                                                 
+   Sturn = 1;
+   if (Sturn)
+     Stangent = 1;
+   if (Sturn)
+     {
+       Sflipped = 0;
+       Snofit = 1;
+       while (Snofit)
+         {
+           Snofit = 0;
+           mindiff = 0;
+           for (i = 0; i < 4; i++)
+             mindiff = diff[i];
+           while (!Snofit && (mindiff < 0.0))
+             {
+               deltay = (Stangent ? deltay : 0.0);
+               if (deltay < 0.0)
+                 Snofit = 1;
+               for (i = 0; i < 4; i++)
+                 {
+                 }
+             }
+           if (Snofit)
+             if (Sflipped)
+               break;
+         }
+       if (Snofit)
+         bar ();
+     }
+ }


More information about the Gcc-patches mailing list