public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bill Schmidt <wschmidt@linux.vnet.ibm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Richard Biener <richard.guenther@gmail.com>
Subject: [PATCH, committed] PR80158 cleanup (alternate interpretations)
Date: Wed, 29 Mar 2017 13:59:00 -0000	[thread overview]
Message-ID: <58b003c4-4c04-922f-89cd-bb79f3c197fc@linux.vnet.ibm.com> (raw)

Hi,

The fix for PR80158 is technically correct, but not "future-proof" in the
sense that someday we may implement more than one alternate interpretation
for a strength reduction candidate.  This patch cleans that up.

Bootstrapped on powerpc64le-unknown-linux-gnu with no regressions,
committed.

Thanks,
Bill


2017-03-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/80158
	* gimple-ssa-strength-reduction.c (replace_mult_candidate):
	Handle possible future case of more than one alternate
	interpretation.
	(replace_rhs_if_not_dup): Likewise.
	(replace_one_candidate): Likewise.


Index: gcc/gimple-ssa-strength-reduction.c
===================================================================
--- gcc/gimple-ssa-strength-reduction.c	(revision 246554)
+++ gcc/gimple-ssa-strength-reduction.c	(working copy)
@@ -2086,11 +2086,15 @@ replace_mult_candidate (slsr_cand_t c, tree basis_
 	  tree lhs = gimple_assign_lhs (c->cand_stmt);
 	  gassign *copy_stmt = gimple_build_assign (lhs, basis_name);
 	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+	  slsr_cand_t cc = c;
 	  gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
 	  gsi_replace (&gsi, copy_stmt, false);
 	  c->cand_stmt = copy_stmt;
-	  if (c->next_interp)
-	    lookup_cand (c->next_interp)->cand_stmt = copy_stmt;
+	  while (cc->next_interp)
+	    {
+	      cc = lookup_cand (cc->next_interp);
+	      cc->cand_stmt = copy_stmt;
+	    }
 	  if (dump_file && (dump_flags & TDF_DETAILS))
 	    stmt_to_print = copy_stmt;
 	}
@@ -2116,12 +2120,16 @@ replace_mult_candidate (slsr_cand_t c, tree basis_
 	  else
 	    {
 	      gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+	      slsr_cand_t cc = c;
 	      gimple_assign_set_rhs_with_ops (&gsi, code,
 					      basis_name, bump_tree);
 	      update_stmt (gsi_stmt (gsi));
               c->cand_stmt = gsi_stmt (gsi);
-	      if (c->next_interp)
-		lookup_cand (c->next_interp)->cand_stmt = gsi_stmt (gsi);
+	      while (cc->next_interp)
+		{
+		  cc = lookup_cand (cc->next_interp);
+		  cc->cand_stmt = gsi_stmt (gsi);
+		}
 	      if (dump_file && (dump_flags & TDF_DETAILS))
 		stmt_to_print = gsi_stmt (gsi);
 	    }
@@ -3406,11 +3414,15 @@ replace_rhs_if_not_dup (enum tree_code new_code, t
 	      || !operand_equal_p (new_rhs2, old_rhs1, 0))))
     {
       gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+      slsr_cand_t cc = c;
       gimple_assign_set_rhs_with_ops (&gsi, new_code, new_rhs1, new_rhs2);
       update_stmt (gsi_stmt (gsi));
       c->cand_stmt = gsi_stmt (gsi);
-      if (c->next_interp)
-	lookup_cand (c->next_interp)->cand_stmt = gsi_stmt (gsi);
+      while (cc->next_interp)
+	{
+	  cc = lookup_cand (cc->next_interp);
+	  cc->cand_stmt = gsi_stmt (gsi);
+	}
 
       if (dump_file && (dump_flags & TDF_DETAILS))
 	return gsi_stmt (gsi);
@@ -3514,11 +3526,15 @@ replace_one_candidate (slsr_cand_t c, unsigned i,
 	  || !operand_equal_p (rhs2, orig_rhs2, 0))
 	{
 	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+	  slsr_cand_t cc = c;
 	  gimple_assign_set_rhs_with_ops (&gsi, MINUS_EXPR, basis_name, rhs2);
 	  update_stmt (gsi_stmt (gsi));
           c->cand_stmt = gsi_stmt (gsi);
-	  if (c->next_interp)
-	    lookup_cand (c->next_interp)->cand_stmt = gsi_stmt (gsi);
+	  while (cc->next_interp)
+	    {
+	      cc = lookup_cand (cc->next_interp);
+	      cc->cand_stmt = gsi_stmt (gsi);
+	    }
 
 	  if (dump_file && (dump_flags & TDF_DETAILS))
 	    stmt_to_print = gsi_stmt (gsi);
@@ -3537,11 +3553,15 @@ replace_one_candidate (slsr_cand_t c, unsigned i,
 	{
 	  gassign *copy_stmt = gimple_build_assign (lhs, basis_name);
 	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+	  slsr_cand_t cc = c;
 	  gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
 	  gsi_replace (&gsi, copy_stmt, false);
 	  c->cand_stmt = copy_stmt;
-	  if (c->next_interp)
-	    lookup_cand (c->next_interp)->cand_stmt = copy_stmt;
+	  while (cc->next_interp)
+	    {
+	      cc = lookup_cand (cc->next_interp);
+	      cc->cand_stmt = copy_stmt;
+	    }
 
 	  if (dump_file && (dump_flags & TDF_DETAILS))
 	    stmt_to_print = copy_stmt;
@@ -3550,11 +3570,15 @@ replace_one_candidate (slsr_cand_t c, unsigned i,
 	{
 	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
 	  gassign *cast_stmt = gimple_build_assign (lhs, NOP_EXPR, basis_name);
+	  slsr_cand_t cc = c;
 	  gimple_set_location (cast_stmt, gimple_location (c->cand_stmt));
 	  gsi_replace (&gsi, cast_stmt, false);
 	  c->cand_stmt = cast_stmt;
-	  if (c->next_interp)
-	    lookup_cand (c->next_interp)->cand_stmt = cast_stmt;
+	  while (cc->next_interp)
+	    {
+	      cc = lookup_cand (cc->next_interp);
+	      cc->cand_stmt = cast_stmt;
+	    }
 
 	  if (dump_file && (dump_flags & TDF_DETAILS))
 	    stmt_to_print = cast_stmt;

                 reply	other threads:[~2017-03-29 13:00 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=58b003c4-4c04-922f-89cd-bb79f3c197fc@linux.vnet.ibm.com \
    --to=wschmidt@linux.vnet.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /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).