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

            Bug ID: 127590
           Summary: wrong code at -O1 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/Wf7n1vP6n

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

[578] % 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/17.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++,lto --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 17.0.0 20260924 (experimental) [master r17-1628-gd1c12591336] (GCC) 
[579] % 
[579] % gcctk -O1 small.c
[580] % timeout -s 9 5 ./a.out
Killed
[581] % cat small.c
struct b {
  int c[2];
  char d;
};
int e, *ac, *ad, **ae, (*af)[], ag, ay, bi, bp;
__attribute__((__vector_size__(sizeof(float)))) float f;
int g(int l) {
  int h[6];
  for (int i = 0; i < 6; ++i)
    h[i] = i;
  unsigned j = e;
  int k = l >>= 8;
  j = h[j ^ k];
  return j;
}
int m();
int n();
int o() {
  struct b ak = {0, 0}, am;
  ae = &ad;
  am = ak;
  af = &am.c;
  ac = *af + 1;
  *ae = ac + 1;
  ag = *ad;
  return ag;
}
void p() {
  while (m())
    ;
}
int m() {
  ay = n();
  return ay;
}
int n() {
  bp = o();
  f[0] = bp;
  bi = g(e);
  bi = g(f[0]);
  return bi;
}
int main() { p(); }

Reply via email to