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

            Bug ID: 124746
           Summary: wrong code at -O{s,2,3} with -fno-tree-fre 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/q4zccWrGc

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

[560] % 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 20260401 (experimental) (GCC)
[561] %
[561] % gcctk -O3 small.c; ./a.out
[562] % gcctk -O3 -fno-tree-fre small.c
[563] % ./a.out
Aborted
[564] % cat small.c
struct a {
  int b;
} c, e = {1}, f;
int d, g, j, *k = &d, n;
static int i;
static struct a *h = &e;
int main() {
  for (; n < 1; n++) {
    int l;
    struct a *m = &c;
  L:
    if (k) {
      d = l = 0;
      for (; l < 1; l++) {
        j = i;
        if (j) {
          struct a **o = &m;
          if (g)
            goto L;
          *o = &f;
        }
      }
    } else
      *h = *m;
  }
  if (e.b != 1)
    __builtin_abort();
  return 0;
}

Reply via email to