The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112875
The patch was successfully tested and bootstrapped on x86-64 and ppc64le.
commit 48cb51827c9eb991b92014a3f59d31eb237ce03f Author: Vladimir N. Makarov <vmaka...@redhat.com> Date: Fri Dec 8 15:37:42 2023 -0500 [PR112875][LRA]: Fix an assert in lra elimination code PR112875 test ran into a wrong assert (gcc_unreachable) in elimination in a debug insn. The insn seems ok. So I change the assertion. To be more accurate I made it the same as analogous reload pass code. gcc/ChangeLog: PR rtl-optimization/112875 * lra-eliminations.cc (lra_eliminate_regs_1): Change an assert. Add ASM_OPERANDS case. gcc/testsuite/ChangeLog: PR rtl-optimization/112875 * gcc.target/i386/pr112875.c: New test. diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc index f3b75e08390..cf229b402da 100644 --- a/gcc/lra-eliminations.cc +++ b/gcc/lra-eliminations.cc @@ -666,6 +666,10 @@ lra_eliminate_regs_1 (rtx_insn *insn, rtx x, machine_mode mem_mode, return x; case CLOBBER: + case ASM_OPERANDS: + gcc_assert (insn && DEBUG_INSN_P (insn)); + break; + case SET: gcc_unreachable (); diff --git a/gcc/testsuite/gcc.target/i386/pr112875.c b/gcc/testsuite/gcc.target/i386/pr112875.c new file mode 100644 index 00000000000..b704404b248 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr112875.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Oz -frounding-math -fno-dce -fno-trapping-math -fno-tree-dce -fno-tree-dse -g" } */ +long a, f; +int b, c, d, g, h, i, j; +char e; +void k(long, int l, char t) { + char m = b, n = g, o = 0; + int p, q, r = h; + long s = g; + if (f) { + q = t + (float)16777217; + o = ~0; + } + if (e) { + d = g + a; + if (d % (a % l)) { + p = d; + n = b; + } + if (l) { + i = b; + r = a; + p = h; + } + if (s) + s = q; + c = f; + e += t; + a = p; + } + j = r % n; + s += g / 0xc000000000000000 + !o; +}