https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116579
Bug ID: 116579
Summary: wrong code at -O{2,3} with "-fno-thread-jumps" 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/ocnbjba4c
It appears to be a recent regression as it doesn't reproduce with 14.2 and
earlier.
[517] % 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/15.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 15.0.0 20240903 (experimental) (GCC)
[518] %
[518] % gcctk -O2 small.c; ./a.out
[519] %
[519] % gcctk -O2 -fno-thread-jumps small.c
[520] % ./a.out
Aborted
[521] %
[521] % cat small.c
int a, c, d, e;
char b;
long f;
int main() {
unsigned char g;
int h = -2, i = 0;
g = a + 128;
d = 0 <= (c || (h = g));
f = h < 0 || i >= 32 ? h : 0;
(b = h) | (e = f);
if (e != 0)
__builtin_abort();
return 0;
}