https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108308
Bug ID: 108308
Summary: wrong code at -Os and -O2 with "-fno-tree-ccp" 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: ---
This appears to be a recent regression as it does not reproduce with 12.2.
Compiler Explorer: https://godbolt.org/z/h1hfa44We
[650] % 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/13.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
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20230105 (experimental) [master r13-5035-g4413365616e] (GCC)
[651] %
[651] % gcctk -Os small.c; ./a.out
[652] %
[652] % gcctk -Os -fno-tree-ccp small.c
[653] % ./a.out
Floating point exception
[654] %
[654] % cat small.c
int a = 1, *d = &a, f = 2766708631, h;
unsigned b = -1, c, e, g;
static void i(int j) {
if (a) {
c = ~c;
while (e)
j = 0;
goto k;
}
l:
h = 1;
k:
*d = (!j) | 80;
int m = ~(~(-1 / b) | (a ^ 1)), n = ~(~g / (11 >> m)), o = -1 / n;
if (f) {
b = 9518150474215344 ^ ~f;
f = 0;
if (c)
goto l;
if (o)
goto k;
}
}
int main() {
i(1);
return 0;
}