public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for another bb
@ 2021-11-17  7:46 apinski
  2021-11-17  7:58 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: apinski @ 2021-11-17  7:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

From: Andrew Pinski <apinski@marvell.com>

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 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.
---
 gcc/testsuite/gcc.c-torture/compile/pr103288-1.c | 6 ++++++
 gcc/tree-ssa-phiopt.c                            | 3 +++
 2 files changed, 9 insertions(+)
 create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr103288-1.c

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))
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for another bb
  2021-11-17  7:46 [PATCH] Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for another bb apinski
@ 2021-11-17  7:58 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-11-17  7:58 UTC (permalink / raw)
  To: apinski, apinski--- via Gcc-patches, gcc-patches; +Cc: Andrew Pinski

On November 17, 2021 8:46:54 AM GMT+01:00, apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>From: Andrew Pinski <apinski@marvell.com>
>
>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.

OK. 
Richard. 

>	PR 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.
>---
> gcc/testsuite/gcc.c-torture/compile/pr103288-1.c | 6 ++++++
> gcc/tree-ssa-phiopt.c                            | 3 +++
> 2 files changed, 9 insertions(+)
> create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr103288-1.c
>
>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))


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-17  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17  7:46 [PATCH] Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for another bb apinski
2021-11-17  7:58 ` Richard Biener

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).