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

            Bug ID: 127130
           Summary: wrong code at -O{2,3} 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/T1PxqrPxE

Note:
- fails: 14.1 to trunk
- works: 13.4 and earlier

[625] % 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 20260829 (experimental) [master r17-1628-gd1c12591336] (GCC) 
[626] % 
[626] % gcctk -O1 small.c; ./a.out
[627] % gcctk -O2 small.c
[628] % ./a.out
Aborted
[629] % cat small.c
short a, *b;
char c, i = 11, j, k, l, m;
int d, e;
long f, g, h, o;
void p(int, float);
void q(long r, long s) {
  if (1613619946 + (2147483645 | r) != s - 2 * r)
    __builtin_abort();
}
__attribute__((noinline)) int t(char r) {
  d = 20715;
  e = 32931 * r;
  d = d + e;
  d = d % 46337;
  p(d, -536870912.0f);
  return 0;
}
void p(int r, float s) {
  g = s;
  f = (long)((unsigned long)g << 16) >> 16;
  h = f ^ r;
  o = -536870890 ^ h;
  q(-35970245861 ^ o, -104686610145);
}
int main() {
  short n = 20158;
  while (1) {
    b = &n;
    a = ~n;
    c = n;
    if (a < -32255)
      break;
    j = n;
    k = j % i;
    m = l = 5;
    m = m * k % i * k;
    l = l + 8 * k + m;
    l = l % i;
    t(l);
    *b = 6303 + n;
  }
  return 0;
}

Reply via email to