public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR77839
@ 2016-10-06  8:13 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2016-10-06  8:13 UTC (permalink / raw)
  To: gcc-patches


The following fixes PR77839 by implementing some more lattice-transition
constraints in SCCVN -- basically make it TOP -> constant value -> value
-> BOTTOM.  This avoids the iteration seen for the testcase in question.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2016-10-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77839
	* tree-ssa-sccvn.c (set_ssa_val_to): Forbid value -> constant value
	lattice transition.

	* gcc.dg/torture/pr77839.c: New testcase.

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c	(revision 240776)
+++ gcc/tree-ssa-sccvn.c	(working copy)
@@ -3260,6 +3306,23 @@ set_ssa_val_to (tree from, tree to)
 	    }
 	  return false;
 	}
+      else if (currval != VN_TOP
+	       && ! is_gimple_min_invariant (currval)
+	       && is_gimple_min_invariant (to))
+	{
+	  if (dump_file && (dump_flags & TDF_DETAILS))
+	    {
+	      fprintf (dump_file, "Forcing VARYING instead of changing "
+		       "value number of ");
+	      print_generic_expr (dump_file, from, 0);
+	      fprintf (dump_file, " from ");
+	      print_generic_expr (dump_file, currval, 0);
+	      fprintf (dump_file, " (non-constant) to ");
+	      print_generic_expr (dump_file, to, 0);
+	      fprintf (dump_file, " (constant)\n");
+	    }
+	  to = from;
+	}
       else if (TREE_CODE (to) == SSA_NAME
 	       && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
 	to = from;
Index: gcc/testsuite/gcc.dg/torture/pr77839.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr77839.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr77839.c	(working copy)
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+
+void
+sd(int yn)
+{
+  while (yn < 1)
+    {
+      int hy;
+      int *n6 = &hy;
+      int **ot = &n6;
+
+      (void)ot;
+      for (yn = 0; yn < 1; ++yn)
+	{
+	  int tc, wo = 0, ez = 0, b8 = 0;
+	  int *ls = &wo;
+
+	  (void)ls;
+	  hy = 0;
+	  for (tc = 0; tc < 1; ++tc)
+	    {
+	      ez ^= hy;
+	      wo ^= ez;
+	      ++b8;
+	    }
+	  hy += (b8 < wo);
+	}
+    }
+}

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

only message in thread, other threads:[~2016-10-06  8:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-06  8:13 [PATCH] Fix PR77839 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).