Bug 48714 - gcc -O hangs gobbling memory, while gcc -O -fno-tree-fre finishes quickly
Summary: gcc -O hangs gobbling memory, while gcc -O -fno-tree-fre finishes quickly
Status: RESOLVED DUPLICATE of bug 48694
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords:
Depends on: 48694
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-21 18:38 UTC by Arthur O'Dwyer
Modified: 2011-04-26 09:20 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.4.5, 4.5.1
Known to fail:
Last reconfirmed: 2011-04-22 09:21:41


Attachments
Output of "ajo-gcc -v -w -O -ftree-fre -c test105974-reduced.c" (648 bytes, text/plain)
2011-04-21 18:38 UTC, Arthur O'Dwyer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur O'Dwyer 2011-04-21 18:38:04 UTC
Created attachment 24067 [details]
Output of "ajo-gcc -v -w -O -ftree-fre -c test105974-reduced.c"

This reproduces for me with svn revision 172796 (2011-04-20), but it doesn't reproduce with gcc-4.4.  I'm on Ubuntu 10.10, x86-64.  Attached "gcc-v.txt".

cat >test105974.c <<EOF
extern volatile int g_4[1][4]; extern int g_7; void modify(int *);
void func_2() {
    int l_46 = 4;
    if (g_7) {
        modify(&l_46);
    } else {
        int i;
        for (i = 0; i != 5; i += 1) {
            volatile int *vp = &g_4[0][l_46]; *vp = 0;
        }
    }
}
EOF
gcc -w -O -c test105974.c
[hangs]
gcc -w -O -fno-tree-fre -c test105974.c
[passes]

This test case is reduced from the output of Csmith (http://embed.cs.utah.edu/csmith/), using the following command line:
csmith --bitfields --packed-struct -s 105974 >test105974.c
gcc -w -I../csmith-2.0.0/runtime -O -c test105974.c

As I said, it reproduces for me only with a home-built bleeding-edge GCC, and I'm still pretty unfamiliar with the GCC build process, so don't bite too hard if this turns out to be user error on my end. ;)
Comment 1 Arthur O'Dwyer 2011-04-21 21:34:41 UTC
Here's another test case with exactly the same symptom. Again, it works with gcc-4.4 but fails with my bleeding-edge gcc. The braces around the inner loop are significant. Notice that the offending assignment to "gp" is actually dead code.

cat >test106865.c <<EOF
extern volatile int g_89[5][9];
extern int g, *gp;
void func_64() {
    int i;
    for (i = 0; i < 1; ) {
        for (g = 0; g < 1; ) {
            return;
        }
        gp = &g_89[g][0];
    }
}
EOF
gcc -w -O1 -c test106865.c
[hangs]
gcc -w -O1 -fno-tree-pre -c test106865.c
[passes]
Comment 2 Richard Biener 2011-04-22 09:21:41 UTC
Mine.  Indeed looks like 48694 - thanks for the small testcases.
Comment 3 Richard Biener 2011-04-26 09:20:14 UTC
Dup.

*** This bug has been marked as a duplicate of bug 48694 ***