public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/52394] SH Target: SH2A defunct bitops
Date: Sun, 20 Sep 2015 10:01:00 -0000	[thread overview]
Message-ID: <bug-52394-4-SovrDfKkMq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52394-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52394

--- Comment #3 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #2)
> 
> The code should actually be something like this:
>         mov.l   .L2,r2
>         bld     #0,r5
>         mov     #0,r0
>         bor.b   #5,@(0,r2)
>         bst.b   #5,@(0,r2)

Actually this might also result in unexpected side-effects when accessing
external hardware, because the volatile mem is accessed with 2x load and 1x
store.  So actually, this sequence can't be really used safely.

Moreover, it seems the code size improvements for those SH2A bitops are not so
big.  The above code is 14 bytes.  The same on non-SH2A could be:

        shlr    r5
        subc    r0,r0
        not     r0,r0
        and     #32,r0
        mov.l   .L5,r2
        mov.b   @r2,r1
        or      r0,r1
        mov.b   r1,@r2

which is 16 bytes.

And the SH2A version of that could be:
        bld     #0,r5
        mov     #0,r0
        bst     #5,r0
        mov.l   .L5,r2
        mov.b   @r2,r1
        or      r0,r1
        mov.b   r1,@r2

which is 14 bytes.

And of course, if GBR can be clobbered it gets down to 8 bytes:
        mov.l   .L5,r2
        ldc     r2,gbr
        mov     #0,r0
        or.b    #32,@(r0,gbr)


      parent reply	other threads:[~2015-09-20 10:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27  2:51 [Bug target/52394] New: " olegendo at gcc dot gnu.org
2012-02-28  0:49 ` [Bug target/52394] " kkojima at gcc dot gnu.org
2015-09-20  3:37 ` olegendo at gcc dot gnu.org
2015-09-20 10:01 ` olegendo at gcc dot gnu.org [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=bug-52394-4-SovrDfKkMq@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).