public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rdsandiford@googlemail.com>
To: gcc-patches@gcc.gnu.org
Subject: Allow more complex call replacements in gimple-fold.c
Date: Mon, 26 Oct 2015 09:44:00 -0000	[thread overview]
Message-ID: <87si4yvuey.fsf@e105548-lin.cambridge.arm.com> (raw)

An upcoming patch adds a match.pd rule that folds pow(pow(x,y),z)
to pow(x,y*z).  This fold can reuse the existing pow gimple statement
and simply replace the operands with x and y*z.  However, the y*z
itself requires a separate gimple statement and the code wasn't
prepared to handle that.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
OK to install?

Thanks,
Richard


gcc/
	* gimple-fold.c (replace_stmt_with_simplification): Allow calls
	to have nonempty sequences.

diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 1869c09..4b9b782 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -3365,7 +3365,14 @@ replace_stmt_with_simplification (gimple_stmt_iterator *gsi,
 	}
       if (i < 3)
 	gcc_assert (ops[i] == NULL_TREE);
-      gcc_assert (gimple_seq_empty_p (*seq));
+      if (dump_file && (dump_flags & TDF_DETAILS))
+	{
+	  fprintf (dump_file, "gimple_simplified to ");
+	  if (!gimple_seq_empty_p (*seq))
+	    print_gimple_seq (dump_file, *seq, 0, TDF_SLIM);
+	  print_gimple_stmt (dump_file, gsi_stmt (*gsi), 0, TDF_SLIM);
+	}
+      gsi_insert_seq_before (gsi, *seq, GSI_SAME_STMT);
       return true;
     }
   else if (!inplace)

             reply	other threads:[~2015-10-26  9:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26  9:44 Richard Sandiford [this message]
2015-10-26 10:14 ` Richard Biener
2015-10-26 10:32   ` Richard Sandiford
2015-10-26 11:25     ` Richard Biener

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=87si4yvuey.fsf@e105548-lin.cambridge.arm.com \
    --to=rdsandiford@googlemail.com \
    --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).