public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "William J. Schmidt" <wschmidt@linux.vnet.ibm.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [Fwd: Re: [PATCH] Add powi-to-multiply expansion to cse_sincos	pass]
Date: Tue, 24 May 2011 17:06:00 -0000	[thread overview]
Message-ID: <1306250888.4821.40.camel@L3G5336.ibm.com> (raw)
In-Reply-To: <BANLkTinhgOpfWipQ1KC6eSeUkAY4UZn7zg@mail.gmail.com>


On Tue, 2011-05-24 at 16:44 +0200, Richard Guenther wrote:
> On Tue, May 24, 2011 at 3:38 PM, William J. Schmidt
> <wschmidt@linux.vnet.ibm.com> wrote:
> >
> > On Tue, 2011-05-24 at 15:11 +0200, Richard Guenther wrote:
> >> On Tue, May 24, 2011 at 2:26 PM, William J. Schmidt
> >> <wschmidt@linux.vnet.ibm.com> wrote:
> >> > Sure, I'll give that a try this morning.  Much obliged.
> >>
> >> Seems it won't work that way without some major changes elsewhere.
> >> Instead follow what update_call_from_tree () does before calling
> >> gsi_replace.
> >
> > Bother.  This won't work, unfortunately.  I can't use gimple_set_vuse ()
> > and gimple_set_vdef () on statements without memory ops.
> 
> You should do
> 
>   if (!gimple_has_mem_ops (new_stmt))
>     unlink_stmt_vdef (old_stmt);

OK, thanks, that's the interface I was struggling to find.

That solved the issue I ran into.  The handling for powi now looks like
this:

		CASE_FLT_FN (BUILT_IN_POWI):
		  arg0 = gimple_call_arg (stmt, 0);
		  arg1 = gimple_call_arg (stmt, 1);
		  if (!host_integerp (arg1, 0))
		    break;

		  n = TREE_INT_CST_LOW (arg1);
		  loc = gimple_location (stmt);
		  result = gimple_expand_builtin_powi (&gsi, loc, arg0, n);

		  if (result)
		    {
		      tree lhs = gimple_get_lhs (stmt);
		      gimple new_stmt = gimple_build_assign (lhs, result);
		      gimple_set_location (new_stmt, loc);
		      move_ssa_defining_stmt_for_defs (new_stmt, stmt);

		      if (gimple_vdef (stmt))
			{
			  gcc_assert (!gimple_has_mem_ops (new_stmt));
			  unlink_stmt_vdef (stmt);
			}

		      gsi_replace (&gsi, new_stmt, true);
		    }
		  break;

gimple_has_mem_ops (new_stmt) will always return false.  The assert is
in place in case we add other powi transforms in the future.

The call to move_ssa_defining_stmt_for_defs requires adding the header
file tree-ssa-propagate.h, and the corresponding dependency in
Makefile.in.

Currently regression testing the "final" fix.  Let me know if you want
to see it one more time before commit.

Thanks as always for your help!

Bill

> 
> > Bill
> >
> >>
> >> Richard.
> >>
> >
> >
> >

  parent reply	other threads:[~2011-05-24 15:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-24  3:59 William J. Schmidt
2011-05-24 15:09 ` Richard Guenther
     [not found]   ` <1306239980.4434.0.camel@gnopaine>
     [not found]     ` <BANLkTikDnSW12C9pBhi-pLScNmgpxPzGoA@mail.gmail.com>
     [not found]       ` <1306244311.4821.31.camel@L3G5336.ibm.com>
     [not found]         ` <BANLkTinhgOpfWipQ1KC6eSeUkAY4UZn7zg@mail.gmail.com>
2011-05-24 17:06           ` William J. Schmidt [this message]
2011-05-24 17:26             ` Richard Guenther

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=1306250888.4821.40.camel@L3G5336.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).