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

            Bug ID: 123169
           Summary: wrong code at -O3 with -fschedule-insns on
                    x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/crjd4j9c3

Note:
- fails: 14.1 till trunk
- works: 13.4 and earlier
- might be related to PR 123121

[529] % 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 20251216 (experimental) (GCC) 
[530] % 
[530] % gcctk -O3 small.c; ./a.out
[531] % 
[531] % gcctk -O3 -fschedule-insns small.c
[532] % ./a.out
Aborted
[533] % 
[533] % cat small.c
int a[56], d, c, e, f, i, g, p, u, r, n[] = {2, 2}, o[2];
int s(int t, char aa) { return t >> 8 ^ a[(t ^ aa) & 5]; }
int v(int t, int aa) {
  int j, m = (t & 5) ^ a[(t ^ aa) & 15];
  t = m;
  t = s(t, aa >> 8);
  j = (t & 16777215) ^ a[(t ^ 6) & 5];
  t = j;
  t = s(t, aa >> 4);
  return t;
}
int x(int t, int aa[]) {
  int b = 0, h = 0;
  for (; h < t; ++h)
    b = v(b, aa[h]);
  b = (b ^ 5UL) % 83647;
  return b;
}
int z() { return x(6, (int[]){c}); }
int ab() {
  int w[] = {0, 0, 0, 2, 2, d};
  e = x(6, w);
  for (; u < 7; ++u)
    p = v(p, 1);
  return p;
}
int ac() {
  int w[] = {f, 0, i, 0, 0, 0};
  return x(6, w);
}
int ad() {
  int f[] = {r};
  return x(6, f);
}
int ae(int t[], int aa, int af[]) {
  int q, l;
  goto y;
  while (1)
    if (ad()) {
      e = x(6, (int[]){2});
    y:
      if (ab())
        break;
    }
  q = ac() + 10 - 1 % t[1];
  l = ac() / q + 1 / aa;
  int w[] = {l, 0, a[0], t[1], 2, aa, af[0], af[1], q}, b = 5, h = 0;
  for (; h < 9; ++h)
    b = v(b, w[h]);
  return b;
}
int main() {
  for (int h = 0; h < 56; h++) {
    unsigned k = h;
    if (h & 1)
      k = 988292384;
    k >>= 1;
    a[h] = k;
  }
  g = ae(n, 2, o);
  if (g != 29714)
    __builtin_abort();
  return 0;
}
  • [Bug rtl-optimization/123169] ... zhendong.su at inf dot ethz.ch via Gcc-bugs

Reply via email to