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-5393] Fix PR 103317, ICE after PHI-OPT, minmax_replacement producing invalid SSA
Date: Fri, 19 Nov 2021 07:20:06 +0000 (GMT)	[thread overview]
Message-ID: <20211119072006.10E623858038@sourceware.org> (raw)

https://gcc.gnu.org/g:09d462146b3107c665265b11ad925c61a91c6efb

commit r12-5393-g09d462146b3107c665265b11ad925c61a91c6efb
Author: Andrew Pinski <apinski@marvell.com>
Date:   Thu Nov 18 23:38:30 2021 +0000

    Fix PR 103317, ICE after PHI-OPT, minmax_replacement producing invalid SSA
    
    The problem is r12-5300-gf98f373dd822b35c allows phiopt to recognize more basic blocks
    but missed one location where the basic block does not need to be empty but still
    needs to have a single predecessor. This patch fixes that over sight.
    
    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
    
            PR tree-optimization/103317
    
    gcc/ChangeLog:
    
            * tree-ssa-phiopt.c (minmax_replacement): For the non empty
            middle bb case, check to make sure it has a single predecessor.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.c-torture/compile/pr103317-1.c: New test.

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

diff --git a/gcc/testsuite/gcc.c-torture/compile/pr103317-1.c b/gcc/testsuite/gcc.c-torture/compile/pr103317-1.c
new file mode 100644
index 00000000000..f9d145e0da9
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr103317-1.c
@@ -0,0 +1,13 @@
+int a, b;
+char c;
+void
+d (void)
+{
+  char e = c;
+  if (b)
+    if (c < 16 - 11)
+      e = 16 - 11;
+  if (e > 8)
+    e = 8;
+  a = e;
+}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index f0431684089..1abc4ea21cc 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1780,6 +1780,9 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
       gimple *assign = last_and_only_stmt (middle_bb);
       tree lhs, op0, op1, bound;
 
+      if (!single_pred_p (middle_bb))
+	return false;
+
       if (!assign
 	  || gimple_code (assign) != GIMPLE_ASSIGN)
 	return false;


                 reply	other threads:[~2021-11-19  7:20 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=20211119072006.10E623858038@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).