From: Andrew Pinski <pinskia@gmail.com>
To: Michael Collison <Michael.Collison@arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>, nd <nd@arm.com>
Subject: Re: [PATCH] [Aarch64] Optimize subtract in shift counts
Date: Mon, 07 Aug 2017 20:44:00 -0000 [thread overview]
Message-ID: <CA+=Sn1mV0mYmmY63OhvGv3LaP64oUt_vM1wFrTQ957JceG+jTA@mail.gmail.com> (raw)
In-Reply-To: <HE1PR0802MB2377266815DA3FBD9F6EF21D95B50@HE1PR0802MB2377.eurprd08.prod.outlook.com>
On Mon, Aug 7, 2017 at 1:36 PM, Michael Collison
<Michael.Collison@arm.com> wrote:
> This patch improves code generation for shifts with subtract instructions where the first operand to the subtract is equal to the bit-size of the operation.
>
>
> long f1(long x, int i)
> {
> return x >> (64 - i);
> }
>
> int f2(int x, int i)
> {
> return x << (32 - i);
> }
>
>
> With trunk at -O2 we generate:
>
> f1:
> mov w2, 64
> sub w1, w2, w1
> asr x0, x0, x1
> ret
>
> f2:
> mov w2, 32
> sub w1, w2, w1
> lsl w0, w0, w1
> ret
>
> with the patch we generate:
>
> f1:
> neg w2, w1
> asr x0, x0, x2
> ret
> .size f1, .-f1
> .align 2
> .p2align 3,,7
> .global f2
> .type f2, %function
> f2:
> neg w2, w1
> lsl w0, w0, w2
> ret
>
> Okay for trunk?
Shouldn't this be handled in simplify-rtx instead of an aarch64
specific pattern?
That is simplify:
(SHIFT A (32 - B)) -> (SHIFT A (AND (NEG B) 31))
etc.
or maybe not. I don't mind either way after thinking about it more.
Thanks,
Andrew
>
> 2017-08-07 Michael Collison <michael.collison@arm.com>
>
> * config/aarch64/aarch64.md (*aarch64_reg_<optab>_minus<mode>3):
> New pattern.
>
> 2016-08-07 Michael Collison <michael.collison@arm.com>
>
> * gcc.target/aarch64/var_shift_mask_2.c: New test.
next prev parent reply other threads:[~2017-08-07 20:44 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 20:36 Michael Collison
2017-08-07 20:44 ` Andrew Pinski [this message]
2017-08-07 21:02 ` Richard Kenner
2017-08-07 23:44 ` Michael Collison
2017-08-08 1:56 ` Richard Kenner
2017-08-08 4:06 ` Michael Collison
2017-08-08 12:13 ` Richard Kenner
2017-08-08 19:46 ` Michael Collison
2017-08-08 19:52 ` Richard Kenner
2017-08-08 19:59 ` Michael Collison
2017-08-08 20:04 ` Richard Kenner
2017-08-08 20:18 ` Michael Collison
2017-08-08 20:20 ` Richard Kenner
2017-08-08 20:33 ` Michael Collison
2017-08-14 8:58 ` Richard Biener
2017-08-15 7:28 ` Michael Collison
2017-08-21 19:11 ` Richard Sandiford
2017-08-21 19:14 ` Richard Biener
2017-08-22 8:17 ` Richard Sandiford
2017-08-22 8:46 ` Richard Biener
2017-08-22 8:50 ` Richard Sandiford
2017-09-06 9:11 ` Michael Collison
2017-09-06 10:32 ` Richard Sandiford
2017-09-06 15:41 ` Michael Collison
2017-09-06 16:53 ` Richard Sandiford
2017-09-06 16:56 ` Richard Sandiford
2017-09-06 17:21 ` Richard Sandiford
2017-09-15 8:15 ` Michael Collison
2017-09-29 23:01 ` James Greenhalgh
2017-08-07 20:58 ` Richard Kenner
2017-08-08 10:04 Wilco Dijkstra
2017-08-22 11:01 Wilco Dijkstra
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='CA+=Sn1mV0mYmmY63OhvGv3LaP64oUt_vM1wFrTQ957JceG+jTA@mail.gmail.com' \
--to=pinskia@gmail.com \
--cc=Michael.Collison@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nd@arm.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).