public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Vladimir Makarov <vmakarov@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-6347] [PR112875][LRA]: Fix an assert in lra elimination code
Date: Fri,  8 Dec 2023 20:52:05 +0000 (GMT)	[thread overview]
Message-ID: <20231208205205.65E333858CD1@sourceware.org> (raw)

https://gcc.gnu.org/g:48cb51827c9eb991b92014a3f59d31eb237ce03f

commit r14-6347-g48cb51827c9eb991b92014a3f59d31eb237ce03f
Author: Vladimir N. Makarov <vmakarov@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:
---
 gcc/lra-eliminations.cc                  |  4 ++++
 gcc/testsuite/gcc.target/i386/pr112875.c | 33 ++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

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;
+}

                 reply	other threads:[~2023-12-08 20:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231208205205.65E333858CD1@sourceware.org \
    --to=vmakarov@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).