https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122973
Bug ID: 122973
Summary: wrong code at -O{2,3} with -fselective-scheduling2 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/jnoMn9Pr4
Note:
- fails: 12.1 and later
- works: 11.4 and earlier
[669] % 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/16.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 16.0.0 20251203 (experimental) (GCC)
[670] %
[670] % gcctk -O3 small.c; ./a.out
[671] %
[671] % gcctk -O3 -fselective-scheduling2 small.c
[672] % ./a.out
Floating point exception
[673] %
[673] % cat small.c
int a[3];
void b(int c, int d, int j[][1]) {
int e = d;
goto f;
g:
if (30 % c)
goto f;
c = j[9][8];
f:
j[1][0] = 1 - d - (7 / c - 1) - 1;
if (j[0][0] >= 0) {
d = 0;
goto h;
}
goto i;
i:
e = 100 / e;
if (c)
d = 0;
h:
d += 2;
c = 1 % e * j[1][0] - 3;
j[0][0] = d = -1 - c - 1 % d;
if (-d - (1 / c - 1) == 0)
goto g;
}
int main() { b(2, 4, (int(*)[])a); }