https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119291
Bug ID: 119291
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: ---
It appears to be a regression from 12.* and affects 13.* and later.
Compiler Explorer: https://godbolt.org/z/saoqG5cvv
[510] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/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.1 20250314 (experimental) (GCC)
[511] %
[511] % gcctk -O3 small.c; ./a.out
[512] % gcctk -O3 -fno-thread-jumps small.c
[513] % timeout -s 9 5 ./a.out
Killed
[514] %
[514] % cat small.c
int a, b, f;
long c;
volatile int d;
int main() {
int e = 1;
L:
if (a < 2) {
b = e;
e = -(~c & (c & -(a && b)));
c = e || c;
a = ~e / ~b;
if (a) {
d;
goto L;
}
}
}