public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5333] Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for another bb
Date: Wed, 17 Nov 2021 08:05:36 +0000 (GMT)	[thread overview]
Message-ID: <20211117080536.9EAFB3858C27@sourceware.org> (raw)

https://gcc.gnu.org/g:1a15a91a0015208eafb797e4de1348c9877fd6d0

commit r12-5333-g1a15a91a0015208eafb797e4de1348c9877fd6d0
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Nov 16 23:37:08 2021 +0000

    Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for another bb
    
    The problem is r12-5300-gf98f373dd822b35c allows phiopt to recognize more basic blocks
    but missed one location where phiopt could move an assignment from the middle block
    to the non-middle one.  This patch fixes that.
    
    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
    
            PR tree-optimization/103288
    
    gcc/ChangeLog:
    
            * tree-ssa-phiopt.c (value_replacement): Return early if middle
            block has more than one pred.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.c-torture/compile/pr103288-1.c: New test.

Diff:
---
 gcc/testsuite/gcc.c-torture/compile/pr103288-1.c | 6 ++++++
 gcc/tree-ssa-phiopt.c                            | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/compile/pr103288-1.c b/gcc/testsuite/gcc.c-torture/compile/pr103288-1.c
new file mode 100644
index 00000000000..88d1c675599
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr103288-1.c
@@ -0,0 +1,6 @@
+
+int ui_5;
+long func_14_uli_8;
+void func_14() {
+        ui_5 &= (func_14_uli_8 ? 60 : ui_5) ? 5 : 0;
+}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 6b22f6bedd4..8984a5e15ab 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1381,6 +1381,9 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
 	}
     }
 
+  if (!single_pred_p (middle_bb))
+    return 0;
+
   /* Now optimize (x != 0) ? x + y : y to just x + y.  */
   gsi = gsi_last_nondebug_bb (middle_bb);
   if (gsi_end_p (gsi))


                 reply	other threads:[~2021-11-17  8:05 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=20211117080536.9EAFB3858C27@sourceware.org \
    --to=pinskia@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).