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

            Bug ID: 129166
           Summary: ICE: in lra_split_hard_reg_for with -m32 -Os/-Oz on
                    impossible asm goto + flag output constraints
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jiangchangwu at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/4efYods5f

*******************************************************************************
Program:
$ cat case.cpp
__attribute__((noinline)) unsigned long r8(unsigned long n) {
    unsigned long a = n, b = n + 1, c = n + 2, d = n + 3;
    unsigned long e = n + 4, f = n + 5, g = n + 6, h = n + 7;
    int z = 0;
    asm goto("testl %[a], %[a]\n\tjnz %l[L]"
             : [a] "+&a"(a), [b] "+&b"(b), [c] "+&c"(c), [d] "+&d"(d),
               [e] "+&S"(e), [f] "+&D"(f), [g] "+&r"(g), [h] "+&r"(h),
               [z] "=@ccz"(z)
             : : "cc" : L);
    return a + b + c + d + e + f + g + h + (unsigned long)z;
L:
    return a ^ n;
}
int main() { return (int)r8(3); }

*******************************************************************************
Tested on GCC 17.0.0 20261130 (0beb11c5cd142242fba819b09808fd86141a60f8)

$ g++ -std=c++23 -m32 -Os -fchecking=2 -c case.cpp (also reproduces with
default checking):
during RTL pass: reload
internal compiler error: maximum number of LRA assignment passes is achieved
(30)

$ g++ -std=c++23 -m32 -Os -fno-checking -c case.cpp:
error: unable to find a register to spill
internal compiler error: in lra_split_hard_reg_for, at lra-assigns.cc:1916

$ g++ -std=c++23 -m32 -O2 -c case.cpp:
Clean diagnostic (`error: 'asm' operand has impossible constraints or there are
not enough registers`), no ICE.
  • [Bug c++/129166] New: IC... jiangchangwu at smail dot nju.edu.cn via Gcc-bugs

Reply via email to