https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121382
Bug ID: 121382
Summary: wrong code at -O2 on x86_64-linux-gnu
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zhendong.su at inf dot ethz.ch
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/oe6Phrb1f
Note:
* Perhaps related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121378
* But this test also fails with 15.1
[512] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20250803 (experimental) (GCC)
[513] %
[513] % gcctk -O2 small.c
[514] % ./a.out
Aborted
[515] % cat small.c
int printf(const char *, ...);
int a, b, c;
static int d(int e, int f) {
do {
f = f - e;
if (c - 9 * f) {
a = b = a ^ 1;
return b;
}
} while (c);
return 0;
}
int main() {
d(5, 1);
d(2147483647, 2147483647);
if (b != 1)
__builtin_abort();
return 0;
}