From: Jeff Law <jeffreyalaw@gmail.com>
To: Roger Sayle <roger@nextmovesoftware.com>, gcc-patches@gcc.gnu.org
Cc: 'Claudiu Zissulescu' <claziss@gmail.com>
Subject: Re: [ARC PATCH] Improve DImode left shift by a single bit.
Date: Mon, 30 Oct 2023 09:09:03 -0600 [thread overview]
Message-ID: <ebbd5fa3-5227-4955-a98e-fd6ebada7bf0@gmail.com> (raw)
In-Reply-To: <010701da099f$76c4a5e0$644df1a0$@nextmovesoftware.com>
On 10/28/23 07:05, Roger Sayle wrote:
>
> This patch improves the code generated for X << 1 (and for X + X) when
> X is 64-bit DImode, using the same two instruction code sequence used
> for DImode addition.
>
> For the test case:
>
> long long foo(long long x) { return x << 1; }
>
> GCC -O2 currently generates the following code:
>
> foo: lsr r2,r0,31
> asl_s r1,r1,1
> asl_s r0,r0,1
> j_s.d [blink]
> or_s r1,r1,r2
>
> and on CPU without a barrel shifter, i.e. -mcpu=em
>
> foo: add.f 0,r0,r0
> asl_s r1,r1
> rlc r2,0
> asl_s r0,r0
> j_s.d [blink]
> or_s r1,r1,r2
>
> with this patch (both with and without a barrel shifter):
>
> foo: add.f r0,r0,r0
> j_s.d [blink]
> adc r1,r1,r1
>
> [For Jeff Law's benefit a similar optimization is also applicable to
> H8300H, that could also use a two instruction sequence (plus rts) but
> currently GCC generates 16 instructions (plus an rts) for foo above.]
>
> Tested with a cross-compiler to arc-linux hosted on x86_64,
> with no new (compile-only) regressions from make -k check.
> Ok for mainline if this passes Claudiu's nightly testing?
WRT H8. Bug filed so we don't lose track of it. We don't have DImode
operations defined on the H8. First step would be DImode loads/stores
and basic arithmetic.
Jeff
next prev parent reply other threads:[~2023-10-30 15:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-28 13:05 Roger Sayle
2023-10-30 15:09 ` Jeff Law [this message]
2023-10-30 15:27 ` Roger Sayle
2023-10-30 15:49 ` Jeff Law
2023-11-03 9:04 ` Claudiu Zissulescu Ianculescu
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=ebbd5fa3-5227-4955-a98e-fd6ebada7bf0@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=claziss@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=roger@nextmovesoftware.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).