public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR77839
Date: Thu, 06 Oct 2016 08:13:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1610061008370.26629@t29.fhfr.qr> (raw)


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);
+	}
+    }
+}

                 reply	other threads:[~2016-10-06  8:13 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=alpine.LSU.2.11.1610061008370.26629@t29.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@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).