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

            Bug ID: 127045
           Summary: wrong code at -O{1,s} on x86_64-linux-gnu (generated
                    code hangs)
           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/3h5bE5fdc

Note:
- fails: trunk
- works: 16.2 and earlier
- might be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127034


[581] % 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 20260824 (experimental) [master r17-1628-gd1c12591336] (GCC) 
[582] % 
[582] % gcctk -O0 small.c; ./a.out
[583] % 
[583] % gcctk -O1 small.c
[584] % timeout -s 9 5 ./a.out
Killed
[585] % 
[585] % cat small.c
float a;
long b, c;
int d, e, f, *g, *h, **i, **l, **m;
short n, o, p, q;
void r(short s, short t) {
  while (-32429 - (-28412 | t) > s)
    ;
}
void u(short s, int t, long v) {
  h = &e;
  i = &g;
  l = &h;
  m = &g;
  if (v == 1073741824) {
    *i = &d;
    *l = *m;
  }
  d = -1610809352 / t;
  f = *h;
  n = f;
  o = n % 181 + 181;
  p = 83;
  q = 25 * o % 181;
  p = p + q;
  r(s - 16044, p + 28236);
}
void w(float s) {
  long j, k;
  a = 8.0f * s;
  b = 2.0f;
  j = a;
  j = j ^ b;
  c = -4294967294 ^ j;
  k = 2 ^ j;
  c = c & k;
  u(-16384, 24, 1073741824 ^ c);
}
int main() { w(536870912.0f); }

Reply via email to