public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/110777 - abnormals and recent PRE optimization
@ 2023-07-24  7:50 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-07-24  7:50 UTC (permalink / raw)
  To: gcc-patches

The following avoids propagating abnormals with the recent tweak
to look through PRE introduced copies between equal values.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/110777
	* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_avail):
	Avoid propagating abnormals.

	* gcc.dg/pr110777.c: New testcase.
---
 gcc/testsuite/gcc.dg/pr110777.c | 22 ++++++++++++++++++++++
 gcc/tree-ssa-sccvn.cc           |  4 +++-
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr110777.c

diff --git a/gcc/testsuite/gcc.dg/pr110777.c b/gcc/testsuite/gcc.dg/pr110777.c
new file mode 100644
index 00000000000..253c2a44d3d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110777.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -w" } */
+
+void pm_message (int);
+int *findOrAddBackgroundInPalette_palette_pnm;
+static void findOrAddBackgroundInPalette(unsigned *paletteSizeP,
+                                    int *backgroundIndexP) {
+  if (*paletteSizeP) {
+    *backgroundIndexP = (*paletteSizeP)++;
+    pm_message(0);
+  }
+  pm_message(findOrAddBackgroundInPalette_palette_pnm[*backgroundIndexP]);
+}
+void computeColorMap(int *backgroundIndexP) {
+  unsigned paletteSize;
+  findOrAddBackgroundInPalette(&paletteSize, backgroundIndexP);
+}
+int main() {
+  unsigned backgroundIndex;
+  _setjmp();
+  computeColorMap(&backgroundIndex);
+}
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index ebe8006bb8b..32e06fae3b9 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -6608,7 +6608,9 @@ eliminate_dom_walker::eliminate_avail (basic_block, tree op)
 	    if (gimple_assign_rhs_class (ass) == GIMPLE_SINGLE_RHS)
 	      {
 		tree rhs1 = gimple_assign_rhs1 (ass);
-		if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) == SSA_NAME)
+		if (CONSTANT_CLASS_P (rhs1)
+		    || (TREE_CODE (rhs1) == SSA_NAME
+			&& !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)))
 		  av = rhs1;
 	      }
 	  return av;
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-24  7:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24  7:50 [PATCH] tree-optimization/110777 - abnormals and recent PRE optimization 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).