public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-8488] regcprop: Avoid DCE of asm goto [PR100590]
Date: Mon, 31 May 2021 14:08:33 +0000 (GMT)	[thread overview]
Message-ID: <20210531140833.B55E4384BC11@sourceware.org> (raw)

https://gcc.gnu.org/g:490ffb47ad10df1793c4894c7c888d7a10576f1a

commit r11-8488-g490ffb47ad10df1793c4894c7c888d7a10576f1a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue May 18 10:26:45 2021 +0200

    regcprop: Avoid DCE of asm goto [PR100590]
    
    The following testcase ICEs, because copyprop_hardreg_forward_1 decides
    to DCE asm goto with REG_UNUSED notes (because the output is unused and
    asm isn't volatile).  But that DCE just removes the asm goto, leaving
    a bb with two successors and no insn at the end that would allow that.
    
    The following patch makes sure we drop that way only INSNs and not
    JUMP_INSNs or CALL_INSNs.
    
    2021-05-18  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/100590
            * regcprop.c (copyprop_hardreg_forward_1): Only DCE dead sets if
            they are NONJUMP_INSN_P.
    
            * gcc.dg/pr100590.c: New test.
    
    (cherry picked from commit c81704b359283bb54696755ead881ab04136da94)

Diff:
---
 gcc/regcprop.c                  |  1 +
 gcc/testsuite/gcc.dg/pr100590.c | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index 7c271e22f47..44f6295b516 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -808,6 +808,7 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd)
       /* Detect obviously dead sets (via REG_UNUSED notes) and remove them.  */
       if (set
 	  && !RTX_FRAME_RELATED_P (insn)
+	  && NONJUMP_INSN_P (insn)
 	  && !may_trap_p (set)
 	  && find_reg_note (insn, REG_UNUSED, SET_DEST (set))
 	  && !side_effects_p (SET_SRC (set))
diff --git a/gcc/testsuite/gcc.dg/pr100590.c b/gcc/testsuite/gcc.dg/pr100590.c
new file mode 100644
index 00000000000..5cd36877fa1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100590.c
@@ -0,0 +1,13 @@
+/* PR rtl-optimization/100590 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-dce -w" } */
+
+int
+foo (void)
+{
+  int x;
+  asm goto ("" : "+r" (x) : : : lab);
+  return 0;
+ lab:
+  return 1;
+}


                 reply	other threads:[~2021-05-31 14:08 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=20210531140833.B55E4384BC11@sourceware.org \
    --to=jakub@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).