public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Roger Sayle <roger@nextmovesoftware.com>,
	'GCC Patches' <gcc-patches@gcc.gnu.org>
Subject: Re: [xstormy16 PATCH] Efficient HImode rotate left by a single bit.
Date: Sat, 29 Apr 2023 10:42:10 -0600	[thread overview]
Message-ID: <dfb3751e-2235-8bad-0421-7e5aa01f0d53@gmail.com> (raw)
In-Reply-To: <004a01d97ab7$42722140$c75663c0$@nextmovesoftware.com>



On 4/29/23 10:25, Roger Sayle wrote:
> This patch contains some minor tweak to xstormy16's machine description
> most significantly providing a pattern for HImode rotate left by a single
> bit that requires only two instructions.
> 
> unsigned short foo(unsigned short x)
> {
>    return (x << 1) | (x >> 15);
> }
> 
> currently with -O2 generates:
> foo:    mov r7,r2
>          shr r7,#15
>          shl r2,#1
>          or r2,r7
>          ret
> 
> with this patch, GCC now generates:
> foo:    shl r2,#1 | adc r2,#0
>          ret
> 
> Additionally neghi2 is converted to a define_insn (so that the RTL
> optimizers see the negation semantics), and HImode rotations by
> 8-bits can now be recognized and implemented using swpb.
> 
> This patch has been tested by building a cross-compiler to xstormy16-elf
> from x86_64-pc-linux-gnu and confirming the new test cases pass.
> Ok for mainline?
> 
> 
> 2023-04-29  Roger Sayle  <roger@nextmovesoftware.com>
> 
> gcc/ChangeLog
>          * config/stormy16/stormy16.md (neghi2): Convert from a define_expand
>          to a define_insn.
>          (*rotatehi_1): New define_insn for efficient 2 insn sequence.
>          (*rotatehi_8, *rotaterthi_8): New define_insn to emit a swpb.
> 
> gcc/testsuite/ChangeLog
>          * gcc.target/xstormy16/neghi2.c: New test case.
>          * gcc.target/rotatehi-1.c: Likewise.
It may be the case that exposing negation as a not + add sequence was 
thought to potentially produce better code by exposing the component 
instructions.  Or it may have simply been the case that nobody 
considered the tradeoffs.


Either way, I think the patch is fine.  As is always the case, figure 
~24hrs after committing we'll have test results.



jeff

      reply	other threads:[~2023-04-29 16:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-29 16:25 Roger Sayle
2023-04-29 16:42 ` Jeff Law [this message]

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=dfb3751e-2235-8bad-0421-7e5aa01f0d53@gmail.com \
    --to=jeffreyalaw@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).