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

--- Comment #3 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
One more likely related test that fails at -O{s,2,3}:
* Compiler Explorer: https://godbolt.org/z/jGzY51ebh
* works: 13.* and earlier
* fails: 14.* and later (the generated code hangs)
* -fwrapv or -fno-ivopts makes it disappear

[528] % 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 20250608 (experimental) (GCC) 
[529] % 
[529] % gcctk -O3 small.c
[530] % timeout -s 9 5 ./a.out
Killed
[531] % cat small.c
int a, b, c, d = -2147483647, e = -2147483647, g = 1;
int main() {
  int f = -2147483647, h = -2149633;
  b = -e - 999 - 2147483647;
  while (1) {
    c = -h;
    while (c + f <= 0) {
      f = -999 * h - 999 - 2147483647;
      h = d - 999 * h - 2147483367;
    }
    a = -999 * g - 1;
    if (999 * a + 999 == 0)
      return 0;
    g = -999 - 999 * b - 999 * f - 2274723;
    while (1) {
      h = -999 * f + h - 999 + 2144057292;
      if (a - 999 * h >= 2147482367)
        break;
    }
  }
}

Reply via email to