public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [rtlanal] Do a better job of costing parallel sets containing flag-setting operations.
Date: Mon, 19 Jun 2017 15:06:00 -0000	[thread overview]
Message-ID: <20170619150607.GL16550@gate.crashing.org> (raw)
In-Reply-To: <09527796-d45b-593e-5f18-7ba15a25c9df@arm.com>

On Mon, Jun 19, 2017 at 03:28:20PM +0100, Richard Earnshaw (lists) wrote:
> > That's not what combine does: it optimistically assumes any combination
> > with unknown costs is an improvement.
> 
> So try this testcase on ARM.
> 
> unsigned long x, y, z;
> int b;
> void test()
> {
>    b = __builtin_sub_overflow (y,z, &x);
> }
> 
> 
> Without the patch, combine rips apart a compare and subtract insn
> because it sees it as having cost zero and substitutes it with separate
> compare and subtract insns.

> The combine log before the patch shows:
> 
> allowing combination of insns 10 and 51
> original costs 0 + 8 = 0
> replacement costs 4 + 12 = 16

Yes, this is a good example of a case where your patch helps.  Thanks.

> So it is clearly deciding that the original costs are greater than the
> replacement costs.

No: it allows any combination with unknown cost (either old or new cost).
See combine_validate_cost.

> >> This patch addresses this problem by allowing insn_rtx_cost to ignore
> >> the condition setting part of a PARALLEL iff there is exactly one
> >> comparison set and one non-comparison set.  If the only set operation is
> >> a comparison we still use that as the basis of the insn cost.
> > 
> > I'll test this on a zillion archs, see what the effect is.
> > 
> > Have you considered costing general parallels as well?
> 
> I thought about it but concluded that there's no generically correct
> answer.  It might be the max of all the individual sets or it might be
> the sum, or it might be somewhere in between.  For example on ARM the
> load/store multiple operations are expressed as parallels, but their
> cost will depend on how many loads/stores happen in parallel within the
> hardware.
> 
> I think we'd need a new back-end hook to handle the other cases sensibly.

And in general make insn_rtx_cost do something more sane than just looking
at a set_src_cost, yeah.

The problem is changing any of this without regressing some targets.
Of course we are in stage 1 now ;-)


Segher

  reply	other threads:[~2017-06-19 15:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19 13:47 Richard Earnshaw (lists)
2017-06-19 14:08 ` Segher Boessenkool
2017-06-19 14:28   ` Richard Earnshaw (lists)
2017-06-19 15:06     ` Segher Boessenkool [this message]
2017-06-19 14:45   ` Richard Earnshaw (lists)
2017-06-19 15:09     ` Segher Boessenkool
2017-06-19 16:01       ` Richard Earnshaw (lists)
2017-06-19 17:41         ` Segher Boessenkool
2017-06-20 12:55           ` Segher Boessenkool
2017-06-30  9:03 ` Richard Earnshaw (lists)
2017-06-30 15:20   ` Jeff Law

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=20170619150607.GL16550@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=Richard.Earnshaw@arm.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).