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

            Bug ID: 124809
           Summary: wrong code at -O1 with "-fno-tree-ch -fno-tree-dce" on
                    x86_64-linux-gnu
           Product: gcc
           Version: 16.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/bYM4oanc6

Note:
- fails: trunk
- works: 15.2 and earlier

[586] % 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.1/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.1 20260407 (experimental) (GCC)
[587] %
[587] % gcctk -O1 small.c; ./a.out
[588] % gcctk -O1 -fno-tree-ch -fno-tree-dce small.c
[589] % ./a.out
Aborted
[590] % cat small.c
unsigned short a, c, d;
int e;
short f(short g, short h) { return h; }
void i(char g) {
  unsigned short j;
  int b, k;
  while (d < 8) {
    if ((b = a != g) ^ a) {
      j = b + a;
      k = j;
      e = a ? 0 : k >> a;
      return;
    }
    b = f(d && c, a);
  }
  while (a)
    b |= g;
}
int main() {
  i(1);
  if (e != 1)
    __builtin_abort();
  return 0;
}

Reply via email to