http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57318

            Bug ID: 57318
           Summary: optimizer takes several seconds on nested loops
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

Current gcc trunk takes 5 seconds to compile this testcase at -O2 or higher
optimization level on x86_64-linux-gnu (2.8GHZ Intel i7).  This was distilled
from larger program which appears to hang gcc, although I suspect it is
actually just extremely slow.

This behavior is not present in 4.8 and older versions.

$ gcc-trunk -v
gcc version 4.9.0 20130517 (experimental) [trunk revision 199006] (GCC) 
$ gcc-trunk -Os hang.c 
$ time gcc-4.8 -O2 hang.c 

real    0m0.101s
user    0m0.072s
sys    0m0.016s
$ time gcc-trunk -O2 hang.c 

real    0m5.289s
user    0m5.232s
sys    0m0.024s

-----------------------------------

struct S0
{
    volatile int f0;
    short f1;
} u;

int a, b;
static struct S0 v;

int main ()
{
    for (a = 0; a <= 9; a++)
    {
        for (b = 0; b <= 9; b++)
            for (u.f1 = 0; u.f1 <= 9; u.f1++)
                v.f0;
    }
}

Reply via email to