https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121577

            Bug ID: 121577
           Summary: wrong code at -O{s,2,3} with "-fno-tree-pre
                    -fno-code-hoisting -fno-tree-fre
                    -fno-tree-dominator-opts -fno-gcse -fno-tree-loop-im"
                    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/ee1vhKGMv

Note:
- works: 10.5 and earlier
- fails: 11.1 and later
- still fails with -fno-tree-slsr and -fno-ivopts
- does seem to require disabling several flags


[777] % 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 20250817 (experimental) (GCC) 
[778] % 
[778] % gcctk -O3 -fno-tree-pre -fno-code-hoisting -fno-tree-fre
-fno-tree-dominator-opts -fno-gcse -fno-tree-loop-im small.c
[779] % ./a.out
Aborted
[780] % cat small.c
int a[] = {-3, 2, -2}, b, d, e;
void f(int g, int h) {
  int i = 12 / h;
  do {
    if (5 / i)
      g = 0;
    e = 5 / i - 6;
  } while (2 / e);
  b = 2 - 5 % i;
  int j[] = {b, 2, g};
  for (int c = 0; c < 3; c++)
    if (j[c] != a[c])
      __builtin_abort();
}
int main() {
  d = 2;
  f(-2, d);
  return 0;
}
  • [Bug tree-optimization/121577]... zhendong.su at inf dot ethz.ch via Gcc-bugs

Reply via email to