Bug 26213 - [4.2 Regression] new (within last few days) infinite loop with -O1
Summary: [4.2 Regression] new (within last few days) infinite loop with -O1
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: compile-time-hog
Depends on:
Blocks:
 
Reported: 2006-02-10 14:10 UTC by Jim Meyering
Modified: 2006-02-10 23:08 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-02-10 14:24:16


Attachments
PPP (664 bytes, text/plain)
2006-02-10 19:23 UTC, Jeffrey A. Law
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Meyering 2006-02-10 14:10:17 UTC
gcc infloops with -O1 (but not -O, -Os, -O2, or -O3) given the following input.
Note that this happens using gcc built from svn a few hours ago, that it is
also reproducible with a two-day-old binary, but not with one from 2006-02-04.

$ cat xnanosleep.c
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;
    }
}
$ time gcc -v -O1 xnanosleep.c 2> /t/err

gcc -v -O1 xnanosleep.c 2> /t/err  0.00s user 0.00s system 0% cpu 5.106 total
[Exit 130 (INT)]
$ cat /t/err
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /mirror/d/gcc/configure --disable-nls --prefix=/p/p/gcc-2006-02-10.10h41 --disable-multilib --enable-languages=c
Thread model: posix
gcc version 4.2.0 20060210 (experimental)
 /nobak/p/p/gcc-2006-02-10.10h41/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.2.0/cc1 -quiet -v -iprefix /nobak/p/p/gcc-2006-02-10.10h41/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.2.0/ xnanosleep.c -quiet -dumpbase xnanosleep.c -mtune=generic -auxbase xnanosleep -O1 -version -o /t/cc9XDV6L.s
ignoring nonexistent directory "/nobak/p/p/gcc-2006-02-10.10h41/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory "/p/p/gcc-2006-02-10.10h41/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/include"
ignoring nonexistent directory "/p/p/gcc-2006-02-10.10h41/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /nobak/p/p/gcc-2006-02-10.10h41/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.2.0/include
 /usr/local/include
 /p/p/gcc-2006-02-10.10h41/include
 /usr/include
End of search list.
GNU C version 4.2.0 20060210 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.2.0 20060210 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: ddb06f39f2f5fb93ee768a85a3be125e
Comment 1 Andrew Pinski 2006-02-10 14:24:16 UTC
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
Comment 2 Jeffrey A. Law 2006-02-10 16:19:04 UTC
Subject: Re:  [4.2 Regression] new (within
	last few days) infinite loop with -O1

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
Fix in testing.
jeff



Comment 3 Jeffrey A. Law 2006-02-10 19:23:02 UTC
Subject: Bug 26213

Author: law
Date: Fri Feb 10 19:22:58 2006
New Revision: 110846

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110846
Log:

	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.


Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr26213.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-threadedge.c

Comment 4 Jeffrey A. Law 2006-02-10 19:23:22 UTC
Subject: Re:  [4.2 Regression] new (within
	last few days) infinite loop with -O1

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.


Comment 5 Jeffrey A. Law 2006-02-10 19:23:22 UTC
Created attachment 10818 [details]
PPP
Comment 6 Andrew Pinski 2006-02-10 23:08:25 UTC
Fixed.