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

            Bug ID: 57281
           Summary: x86_64-linux loop fails to terminate at -O3 -m32
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

The testcase below is miscompiled with current gcc trunk at -O3 optimization
level in 32-bit mode on x86_64-linux-gnu, and fails to terminate.  With other
optimizations levels in 64-bit mode, it executes successfully.  This is a
regression from 4.8, where the code works at all optimizations levels.

$ gcc-trunk -v
...
Target: x86_64-unknown-linux-gnu
gcc version 4.9.0 20130514 (experimental) [trunk revision 198875] (GCC)
$ gcc-trunk -O2 -m32 test.c
$ ./a.out
$ gcc-4.8 -O3 -m32 test.c
$ ./a.out
$ gcc-trunk -O3 -m32 test
$ ./a.out
<hangs>


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

int a = 1, b = 0, d;
long long c;
int *e = &d;
volatile long long f;
long long *g = &c;

int foo(int h)
{
  int j = *g = b;
  return h == 0 ? j : 0;
}

int
main ()
{
    int h = a;
    for (; b != -20; b--)
    {
        int i = f;
        *e = 0;
        *e = foo(h);
    }
    return 0;
}

Reply via email to