[Bug tree-optimization/26213] [4.2 Regression] new (within last few days) infinite loop with -O1

Jeffrey A Law law@redhat.com
Fri Feb 10 19:23:00 GMT 2006


On Fri, 2006-02-10 at 14:24 +0000, pinskia at gcc dot gnu dot org wrote:
> 
> ------- Comment #1 from pinskia at gcc dot gnu dot org  2006-02-10 14:24 -------
> Confirmed, the backtrace:
> #0  0x004c0784 in thread_across_edge (dummy_cond=0x41ee29f0, e=0x41ee24e0,
> handle_dominating_asserts=0 '\0', stack=0x6c9530, simplify=0x422674
> <simplify_stmt_for_jump_threading>) at
> /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssa-threadedge.c:445
> #1  0x0042359c in dom_opt_finalize_block (walk_data=0x41ee24e0, bb=0x41ee21b0)
> at /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssa-dom.c:722
> #2  0x0042359c in dom_opt_finalize_block (walk_data=0xbffff80c, bb=0x41ee1930)
> at /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssa-dom.c:722
> #3  0x0049b044 in walk_dominator_tree (walk_data=0xbffff80c, bb=0x41ee1930) at
> /Users/pinskia/src/gcc/local/gcc/gcc/domwalk.c:234
> #4  0x0049aff0 in walk_dominator_tree (walk_data=0xbffff80c, bb=0x41ee1850) at
> /Users/pinskia/src/gcc/local/gcc/gcc/domwalk.c:212
> #5  0x0049aff0 in walk_dominator_tree (walk_data=0xbffff80c, bb=0x41ee1770) at
> /Users/pinskia/src/gcc/local/gcc/gcc/domwalk.c:212
> #6  0x0049aff0 in walk_dominator_tree (walk_data=0xbffff80c, bb=0x41ee15b0) at
> /Users/pinskia/src/gcc/local/gcc/gcc/domwalk.c:212

I should have known better.  It's possible to have loops in the
SSA_NAME_VALUE chain.  Dumb dumb dumb.  

Bootstrapped and regression tested on i686-pc-linux-gnu.


-------------- next part --------------
	PR tree-optimization/26213
	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Do not
	loop trying to follow SSA_NAME_VALUE chains.

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

Index: tree-ssa-threadedge.c
===================================================================
*** tree-ssa-threadedge.c	(revision 110840)
--- tree-ssa-threadedge.c	(working copy)
*************** simplify_control_stmt_condition (edge e,
*** 441,450 ****
      {
        cached_lhs = cond;
  
!       /* Get the variable's current value from the equivalency chains.  */
!       while (cached_lhs
! 	     && TREE_CODE (cached_lhs) == SSA_NAME
! 	     && SSA_NAME_VALUE (cached_lhs))
  	cached_lhs = SSA_NAME_VALUE (cached_lhs);
  
        /* If we're dominated by a suitable ASSERT_EXPR, then
--- 441,454 ----
      {
        cached_lhs = cond;
  
!       /* Get the variable's current value from the equivalency chains.
! 
! 	 It is possible to get loops in the SSA_NAME_VALUE chains
! 	 (consider threading the backedge of a loop where we have
! 	 a loop invariant SSA_NAME used in the condition.  */
!       if (cached_lhs
! 	  && TREE_CODE (cached_lhs) == SSA_NAME
! 	  && SSA_NAME_VALUE (cached_lhs))
  	cached_lhs = SSA_NAME_VALUE (cached_lhs);
  
        /* If we're dominated by a suitable ASSERT_EXPR, then
Index: gcc/testsuite/gcc.c-torture/compile/pr26213.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr26213.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr26213.c	(revision 0)
***************
*** 0 ****
--- 1,15 ----
+ void
+ xnanosleep (_Bool overflow)
+ {
+   struct { int tv_nsec; } ts_sleep;
+   if (0 <= ts_sleep.tv_nsec)
+     overflow |= 1;
+ 
+   for (;;)
+     {
+       if (overflow)
+         ts_sleep.tv_nsec = 0;
+       if (foo (ts_sleep))
+         break;
+     }
+ }


More information about the Gcc-patches mailing list