https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117239
Bug ID: 117239
Summary: wrong code at -O{s,2} with "-fno-inline
-fschedule-insns" on x86_64-linux-gnu
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-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 11.*, and affects 12.* and later.
Compiler Explorer: https://godbolt.org/z/b86d6z9bf
[526] % 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.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 20241020 (experimental) (GCC)
[527] %
[527] % gcctk -O2 small.c; ./a.out
[528] % gcctk -O2 -fno-inline -fschedule-insns small.c
[529] % ./a.out
Aborted
[530] % cat small.c
int a, b, j = 1, k;
int l() { return a; }
struct c {
int d;
int e;
int f;
int g;
short h;
int i;
};
void m(int n, struct c o) {
if (o.i)
j = 0;
}
int r(struct c n) { return b; }
int main() {
struct c q = {0, 0, 0, 0, 0, 1};
k = r(q);
m(l(), q);
if (j != 0)
__builtin_abort();
return 0;
}