https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68955
Bug ID: 68955
Summary: wrong code at -O3 on x86-64-linux-gnu in 32-bit mode
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
Target Milestone: ---
The following code is miscompiled by the gcc trunk at -O3 on x86-64-linux-gnu
in 32-bit mode (not in 64-bit mode).
$: gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 6.0.0 20151217 (experimental) [trunk revision 231731] (GCC)
$:
$: gcc-trunk -O3 -m32 -w small.c ; ./a.out
0
$: gcc-trunk -w small.c ; ./a.out
1
$: cat small.c
int printf (const char *, ...);
int a, b, c, d, g, m;
int i[7][7][5] = { {{5}}, {{5}}, {{5}, {5}, {5}, {5}, {5}, {-1}} };
static int j = 11;
short e, f, h, k, l;
static void
fn1 ()
{
for (; e < 5; e++)
for (h = 3; h; h--)
{
for (g = 1; g < 6; g++)
{
m = c == 0 ? b : b / c;
i[e][1][e] = i[1][1][1] | (m & l) && f;
}
for (k = 0; k < 6; k++)
{
for (d = 0; d < 6; d++)
i[1][e][h] = i[h][k][e] >= l;
i[e + 2][h + 3][e] = 6 & l;
i[2][1][2] = a;
for (; j < 5;)
for (;;)
;
}
}
}
int
main ()
{
fn1 ();
printf ("%d\n", i[1][0][2]);
return 0;
}
$: