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

            Bug ID: 128716
           Summary: powerpc64le: LRA does not terminate at -O1
                    (-mcpu=power8) with _BitInt
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: compile-time-hog
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shimizu2486 at gmail dot com
  Target Milestone: ---
            Target: powerpc64le-linux-gnu

Live reproducer: https://godbolt.org/z/de7T3Yxea

$ cat t1.c
unsigned g, c, w, m, y, t, i;
__int128 z, d, e, v;
_BitInt(96) u;
_BitInt(127) s;
_BitInt(65) r;
__int128 sub(__int128 a, __int128 b) {
  return __builtin_sub_overflow(a, b, &d) ? a : d;
}
int h(void);
int main(void) {
  int x, k = h();
  for (; w; w++) {
    m = s;
    for (; i < m; i++)
      s = g ? g : sub(x, c) ^ m;
    z = v;
    if (x && y)
      u = (__builtin_mul_overflow(2, t, &r) ? 0 : r) | (unsigned __int128)x;
    v = e;
  }
  return k;
}

The program is only compiled (it reads an uninitialized local var).

$ timeout 300 powerpc64le-linux-gnu-gcc -O1 -c t1.c; echo $?
124

cc1 does not finish.  In the reload dump (-fdump-rtl-reload) of main, I observe
LRA cycles: the first second of the dump has about 700 assignment passes, and
every second one reloads a TImode value through a new 16-byte stack slot
(sfp+0x30, +0x60, +0x70, ...)

  powerpc64le trunk (372c32f9)               hangs
  powerpc64le trunk 20261007 (152e49bf)      hangs
  powerpc64le trunk 20261006 (028b8b62)      compiles in under a second

-O0, -O2, -O3, -Os and -Og compile it in under a second, and so do -mcpu=power9
and -mcpu=power10.
-fira-region=one and -fno-checking still hang.
powerpc64 (big-endian) hangs too with -mcpu=power8.
x86-64, riscv64 and aarch64 compile it at -O1.

found by fuzzer.

Reply via email to