From: Jakub Jelinek <jakub@redhat.com>
To: Georg-Johann Lay <avr@gjlay.de>
Cc: Jeff Law <law@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Optimize divmod expansion (PR middle-end/79665)
Date: Wed, 31 May 2017 09:08:00 -0000 [thread overview]
Message-ID: <20170531090041.GR24023@tucnak> (raw)
In-Reply-To: <fe405f3e-d67e-db3d-4c70-8cc42b3da1a3@gjlay.de>
On Wed, May 31, 2017 at 10:48:07AM +0200, Georg-Johann Lay wrote:
> > > because divmod in not a single_set:
> > > (gdb) p seq
> > > $10 = (const rtx_insn *) 0x7ffff730d500
> > > (gdb) pr
> > > warning: Expression is not an assignment (and might have no effect)
> > > (insn 14 13 0 (parallel [
> > > (set (reg:HI 52)
> > > (div:HI (reg:HI 47)
> > > (reg:HI 54)))
> > > (set (reg:HI 53)
> > > (mod:HI (reg:HI 47)
> > > (reg:HI 54)))
> > > (clobber (reg:QI 21 r21))
> > > (clobber (reg:HI 22 r22))
> > > (clobber (reg:HI 24 r24))
> > > (clobber (reg:HI 26 r26))
> > > ]) "scale.c":7 -1
> > > (nil))
> > > (gdb)
> > >
> > > Hence the divmod appears to be much less expensive than the unsigned
> > > variant that computed the costs for mult_highpart.
> >
> > Then you should fix the cost computation - be able to use a target hook
> > on insns that are not a single set or something similar.
>
> Are you saying that cost computation in GCC is fundamentally flawed
> for anything that it not a single_set?
The division/modulo optimization I've added as well as many other spots
in GCC rely on reasonable cost, just grep e.g. all places that call
seq_cost. So, if it returns something that is a very wrong estimate,
it won't affect just that single optimization, but all others. Therefore,
you should fix the cost computation, rather than disabling all the places
that use the costs. Many targets have instructions with multiple sets,
so I'm surprised assuming cost of 1 for them doesn't break many more things.
I think either we should have a separate target hook for multiple sets
instructions, or just call the targetm.rtx_costs on the PARALLEL in that
case and see if the targets compute something reasonable for it, otherwise
either use the cost of the first set, or maximum of all sets (that might be
best) or something similar.
Jakub
next prev parent reply other threads:[~2017-05-31 9:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 21:50 Jakub Jelinek
2017-02-23 6:00 ` Jeff Law
2017-05-31 8:15 ` Georg-Johann Lay
2017-05-31 8:19 ` Jakub Jelinek
2017-05-31 9:00 ` Georg-Johann Lay
2017-05-31 9:08 ` Jakub Jelinek [this message]
2017-05-31 14:04 ` Georg-Johann Lay
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=20170531090041.GR24023@tucnak \
--to=jakub@redhat.com \
--cc=avr@gjlay.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@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).