]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR112875][LRA]: Fix an assert in lra elimination code
authorVladimir N. Makarov <vmakarov@redhat.com>
Fri, 8 Dec 2023 20:37:42 +0000 (15:37 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Fri, 8 Dec 2023 20:51:12 +0000 (15:51 -0500)
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.

gcc/lra-eliminations.cc
gcc/testsuite/gcc.target/i386/pr112875.c [new file with mode: 0644]

index f3b75e083901746d6aeb17819c8272a63adab9d2..cf229b402daa35c771847d20fee7bb943a6654b9 100644 (file)
@@ -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 (file)
index 0000000..b704404
--- /dev/null
@@ -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;
+}