https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61786
--- Comment #1 from Zhendong Su <su at cs dot ucdavis.edu> ---
Not sure whether it is due to the same root cause, but the combined code is
also miscompiled at (only) -O2 by the current trunk.
Interestingly, -flto seems to make the miscompilation disappear.
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
Target: x86_64-unknown-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 4.10.0 20140711 (experimental) [trunk revision 212447] (GCC)
$
$ gcc-trunk -Os small.c; a.out
$ gcc-trunk -O3 small.c; a.out
$ gcc-4.9 -O2 small.c; a.out
$ gcc-trunk -flto -O2 small.c; a.out
$
$ gcc-trunk -O2 small.c
$ a.out
^C
$
$
---------------------
int a, *c = &a, d;
char b = 1;
void
fn1 ()
{
d = 1;
lbl:
if (b == d)
{
d = *c;
if (b)
goto lbl;
}
}
int
fn2 ()
{
fn1 ();
return 0;
}
int
main ()
{
fn2 ();
return 0;
}