public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steven Bosscher <stevenb.gcc@gmail.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Andreas Krebbel <krebbel@linux.vnet.ibm.com>,
	gcc-patches@gcc.gnu.org, 	Richard Henderson <rth@redhat.com>
Subject: Re: [PATCH] widening_mul: Do cost check when propagating mult into plus/minus expressions
Date: Wed, 13 Jul 2011 23:29:00 -0000	[thread overview]
Message-ID: <CABu31nNHKw1P2WWdd--WDkSqbYtW-Va-A6MXqsZE05DFNKRF6g@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc0OpHGr8_45xXq7=Xmxp1uApGFkRyt-f5_yXwOrKzgZzw@mail.gmail.com>

On Wed, Jul 13, 2011 at 4:34 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Wed, Jul 13, 2011 at 3:13 PM, Andreas Krebbel
> <krebbel@linux.vnet.ibm.com> wrote:
>> Hi,
>>
>> the widening_mul pass might increase the number of multiplications in
>> the code by transforming
>>
>> a = b * c
>> d = a + 2
>> e = a + 3
>>
>> into:
>>
>> d = b * c + 2
>> e = b * c + 3
>>
>> under the assumption that an FMA instruction is not more expensive
>> than a simple add.  This certainly isn't always true.  While e.g. on
>> s390 an fma is indeed not slower than an add execution-wise it has
>> disadvantages regarding instruction grouping.  It doesn't group with
>> any other instruction what has a major impact on the instruction
>> dispatch bandwidth.
>>
>> The following patch tries to figure out the costs for adds, mults and
>> fmas by building an RTX and asking the backends cost function in order
>> to estimate whether it is whorthwhile doing the transformation.
>>
>> With that patch the 436.cactus hotloop contains 28 less
>> multiplications than before increasing performance slightly (~2%).
>>
>> Bootstrapped and regtested on x86_64 and s390x.
>
> Ick ;)

+1

> Maybe this is finally the time to introduce target hook(s) to
> get us back costs for trees?  For this case we'd need two
> actually, or just one - dependent on what finegrained information
> we pass.  Choices:
>
>  tree_code_cost (enum tree_code)
>  tree_code_cost (enum tree_code, enum machine_mode mode)
>  unary_cost (enum tree_code, tree actual_arg0) // args will be mostly
> SSA names or constants, but at least they are typed - works for
> mixed-typed operations
>  binary_cost (...)
>  ...
>  unary_cost (enum tree_code, enum tree_code arg0_kind) // constant
> vs. non-constant arg, but lacks type/mode

Or maybe add a cost function for all named insns (i.e.
http://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html#Standard-Names)?
I think that any form of lower GIMPLE will not be so low level that
more combinations will exist than the available named patterns. It
should be possible to write a gen* tool using rtx_costs to compute
some useful cost metric for all named patterns. How complicated that
could be (modes, reg vs. mem, etc.), I don't know... But at least that
way we don't end up with multiple target costs depending on the IR in
use.

Ciao!
Steven

  parent reply	other threads:[~2011-07-13 21:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13 13:26 Andreas Krebbel
2011-07-13 14:49 ` Richard Guenther
2011-07-13 15:27   ` Georg-Johann Lay
2011-07-13 23:29   ` Steven Bosscher [this message]
2011-07-14  9:43     ` Richard Guenther
2011-07-14 16:16       ` Steven Bosscher
2011-07-15  9:06       ` Andreas Krebbel
2011-07-14  7:45   ` Andreas Krebbel
2011-07-13 17:08 ` Richard Henderson
2011-07-14  9:28   ` Andreas Krebbel
2011-07-14 13:32   ` Andreas Krebbel

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=CABu31nNHKw1P2WWdd--WDkSqbYtW-Va-A6MXqsZE05DFNKRF6g@mail.gmail.com \
    --to=stevenb.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=krebbel@linux.vnet.ibm.com \
    --cc=richard.guenther@gmail.com \
    --cc=rth@redhat.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).