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

            Bug ID: 123048
           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/jefb6TP74

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

[515] % 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 20251208 (experimental) (GCC) 
[516] % 
[516] % gcctk -O3 small.c; ./a.out
[517] % gcctk -O3 -fschedule-insns small.c
[518] % ./a.out
Aborted
[519] % cat small.c
int a[] = {
    4,           7,         5,          5,         54,         2044508324,
    0,           4,         7,          4049,      8,          6,
    4089016648,  4,         50548861,   3,         107580753,  9,
    2,           6,         7,          5,         5,          7,
    7073096,     6,         2,          2,         1006888145, 607687,
    101629,      3,         901097722,  9000684,   6,          8065728,
    1,           1,         705015759,  5,         0,          6,
    4,           104598,    3,          1,         5,          3099436303,
    4,           4,         30930,      70347812,  7,          5,
    -1810856918, 907459465, 5,          3,         904427059,  2013776290,
    6,           4,         0,          3,         3,          9,
    7,           802195444, 6,          8001368,   4066508878, 70925,
    3092731,     5,         706088902,  4,         2,          2,
    1,           7,         3,          5,         303535960,  6,
    7007092,     9037538,   70817,      1,         3,          4079995,
    6,           6,         909243462,  6,         7,          7,
    1,           708648649, 8,          6,         6048,       4,
    909,         5,         10523913,   5,         4,          702138776,
    0,           2,         504918807,  3,         3082640443, 9,
    4,           6,         7068,       10842,     1,          70997,
    3,           0,         4,          0,         2053790376, 90386,
    2,           2050814,   5,          5,         0,          6,
    2,           708143,    5,          3,         7,          604390888,
    8,           2,         6,          5,         60999,      1068828381,
    9,           0,         8,          906185462, 1090812512, 3,
    9,           5,         1,          4,         60834842,   8085408,
    6,           109,       8078467,    3,         400815,     2,
    608,         4,         6,          5,         3,          1,
    607071920,   0,         2,          40735498,  5,          1,
    3087877,     908371,    4,          803740692, 2075208622, 2,
    3,           90285,     2094854071, 1,         2029012,    0,
    2,           0,         1,          5,         1,          7,
    4,           200368,    4,          405801727, 5,          5,
    1,           5067896,   608007406,  308918612, 8,          808555105};
int c, d, e, k, j[3] = {1,2}, *l;
unsigned h;
int n(int o, unsigned p) { return o >> 8 ^ a[(o ^ p) & 255]; }
int fn2(int o, int p) {
  d = (o >> 8 & 16777215) ^ a[(o ^ p) & 255];
  o = d;
  o = n(o, p >> 8 & 255);
  o = n(o, p >> 6);
  c = o >> 8 ^ a[(o ^ 24) & 255];
  return c;
}
int q(int o, int p, int r[], int s) {
  unsigned b = -1;
  int m, f;
  m = -1 - o;
  if (m + e)
    goto ag;
  do {
    while (k)
      ;
    for (int i = 0; i < 6; ++i)
      h = fn2(h, l[i]);
  } while (o);
ag:
  f = -(1 % r[1]);
  m = 1 / s;
  int a[] = {o, p, r[0], r[1], r[2], f, m, s};
  for (int i = 0; i < 8; i++)
    b = fn2(b, a[i]);
  return b;
}
int main() {
  int g = q(-5, 1, j, 2);
  if (g != 4639)
    __builtin_abort();
  return 0;
}

Reply via email to