https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119872
Bug ID: 119872
Summary: [15 regression] wrong code at -O{1,2,s}
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: chopra.kavya04 at gmail dot com
Target Milestone: ---
appears to be a regression from 15. godbolt link:
https://godbolt.org/z/a5rGvbcjK
kchopra@ast-epyc4:/local/home/kchopra$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/local/home/kchopra/compilers/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-bootstrap --enable-checking=yes
--prefix=/local/home/kchopra/compilers --enable-sanitizers
--enable-languages=c,c++ --disable-werror --enable-multilib : (reconfigured)
../configure --disable-bootstrap --enable-checking=yes
--prefix=/local/home/kchopra/compilers --enable-sanitizers
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.1 20250414 (experimental) (GCC)
kchopra@ast-epyc4:/local/home/kchopra$ vim static_bug.c
kchopra@ast-epyc4:/local/home/kchopra$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/local/home/kchopra/compilers/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-bootstrap --enable-checking=yes
--prefix=/local/home/kchopra/compilers --enable-sanitizers
--enable-languages=c,c++ --disable-werror --enable-multilib : (reconfigured)
../configure --disable-bootstrap --enable-checking=yes
--prefix=/local/home/kchopra/compilers --enable-sanitizers
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.1 20250414 (experimental) (GCC)
kchopra@ast-epyc4:/local/home/kchopra$ gcc -O0 static_bug.c; ./a.out
kchopra@ast-epyc4:/local/home/kchopra$ gcc -O1 static_bug.c; ./a.out
Aborted
kchopra@ast-epyc4:/local/home/kchopra$ gcc -O2 static_bug.c; ./a.out
Aborted
kchopra@ast-epyc4:/local/home/kchopra$ gcc -Os static_bug.c; ./a.out
Aborted
kchopra@ast-epyc4:/local/home/kchopra$ gcc -O3 static_bug.c; ./a.out
kchopra@ast-epyc4:/local/home/kchopra$ cat static_bug.c
int a ;
int b ;
static int c = -757;
int d ;
int e = 418;
static int f = -4;
int g = 751;
int h ;
int main() {
i:
b = 80 * f + 44 * c -100654797;
goto m;
j:
if (d ) goto k;
goto l;
k:
b = 792555486 * c + 4025695 * g + 764167704;
m:
h = 75 * e -g + 965860133;
goto r;
l:
h = h -100 * a -282547080;
if (36 * h + a >= 0) goto n;
goto o;
n:
a = 13 * b -9 * c + 1295216013;
if (-a >= 0) goto j;
goto i;
r:
g = 35 * e -h + 756029830;
if (-g + 1073741824 >= 0) goto p;
goto q;
p:
e = 77 * c -21489822;
goto i;
q:
goto n;
o:
d = -74 * h -99 * f -43630944;
if(d != 131988990) __builtin_abort();
}