https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128171
Bug ID: 128171
Summary: wrong code at -O{s,2,3} with "-fwhole-program
-fno-inline" on x86_64-linux-gnu
Product: gcc
Version: 17.0
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/3bxcW6PP9
Note:
- fails: 15.1 till trunk
- works: 14.4 and earlier
[543] % 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/17.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++,lto --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 17.0.0 20261026 (experimental) [master r17-1628-gd1c12591336] (GCC)
[544] %
[544] % gcctk -O3 small.c; ./a.out
[545] %
[545] % gcctk -O3 -fwhole-program -fno-inline small.c
[546] % ./a.out
Illegal instruction
[547] %
[547] % cat small.c
int a, b, c;
int e(int f) {
return a / f;
}
void g(int f) { b = e(f > 0 ? f : 0); }
int main() {
if (c)
g(0);
g(1);
return 0;
}