public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Robin Dapp <rdapp@linux.ibm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Andrew Pinski <pinskia@gmail.com>
Subject: Re: [PATCH] expand: Convert cst - x into cst xor x.
Date: Wed, 7 Sep 2022 14:45:51 +0200	[thread overview]
Message-ID: <CAFiYyc2hFNpnqyHUYEFM1DPXGUct4rn2zp329on0osc_SL45jw@mail.gmail.com> (raw)
In-Reply-To: <3d928191-a2f5-f314-c03b-d4e590282ce9@linux.ibm.com>

On Wed, Sep 7, 2022 at 2:20 PM Robin Dapp <rdapp@linux.ibm.com> wrote:
>
> > The question is really whether xor or sub is "better" statically.  I can't
> > think of any reasons.  On s390, why does xor end up "better"?
>
> There is an xor with immediate (as opposed to no "subtract from
> immediate") which saves an instruction, usually.  On x86, I think the
> usual argument for xor is that it's shorter (if flags etc. are not needed).
>
> It's not that I don't want to implement it in the backend, just that I
> understood the original PR in a way that it would make sense to have
> this conversion available for more targets.  If there are too many
> confounding factors that prevent this situation from being statically
> costed properly, then sure, not much use in implementing it generally.

Do we have evidence that targets properly cost XOR vs SUB RTXen?

It might actually be a reload optimization - when the constant is
available in a register use 'sub', when it needs to be reloaded
use 'xor'?

That said, I wonder if the fallout of changing some SUB to XOR
is bigger than the benefit when we do it early (missed combines, etc.)?

> Regards
>  Robin

  reply	other threads:[~2022-09-07 12:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06  9:42 Robin Dapp
2022-09-06 12:31 ` Richard Biener
2022-09-06 14:01   ` Robin Dapp
2022-09-07 12:08     ` Richard Biener
2022-09-07 12:20       ` Robin Dapp
2022-09-07 12:45         ` Richard Biener [this message]
2022-09-07 16:30           ` Jeff Law
2022-10-21  9:13           ` Robin Dapp

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=CAFiYyc2hFNpnqyHUYEFM1DPXGUct4rn2zp329on0osc_SL45jw@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=pinskia@gmail.com \
    --cc=rdapp@linux.ibm.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).