public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/65266] New: [SH] Use rotcl for bit reversals
@ 2015-03-01 20:45 olegendo at gcc dot gnu.org
  2021-08-28  3:51 ` [Bug target/65266] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-03-01 20:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65266
           Summary: [SH] Use rotcl for bit reversals
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
            Target: sh*-*-*

The following examples are small bit reversals:

unsigned int test1 (unsigned int a)
{
  return ((a & 1) << 1) | ((a >> 1) & 1);
}

unsigned int test2 (unsigned int a)
{
  return ((a & 1) << 2) | (((a >> 1) & 1) << 1) | ((a >> 2) & 1);
}

unsigned int test3 (unsigned int a)
{
  return ((a & 1) << 3) | (((a >> 1) & 1) << 2) | (((a >> 2) & 1) << 1)
         | (((a >> 3) & 1) << 0);
}

where test3 currently compiles to:
        mov     r4,r0
        mov     #1,r2
        tst     #8,r0
        and     r4,r2
        movt    r1
        mov     r2,r0
        shll2   r0
        tst     r1,r1
        mov     r0,r1
        mov     r4,r0
        and     #2,r0
        rotcl   r1
        add     r0,r0
        mov     r0,r2
        mov     r4,r0
        or      r1,r2
        tst     #4,r0
        mov     #-1,r1
        mov     r2,r0
        negc    r1,r1
        add     r1,r1
        rts
        or      r1,r0

where a minimal sequence would be:
        shlr    r4
        movt    r0
        shlr    r4
        rotcl   r0
        shlr    r4
        rotcl   r0
        shlr    r4
        rotcl   r0


For example, combine tries the following pattern:

Failed to match this instruction:
(set (reg:SI 186 [ D.2006 ])
    (ior:SI (ior:SI (and:SI (ashift:SI (reg/v:SI 176 [ a ])
                                       (const_int 1 [0x1]))
                            (const_int 4 [0x4]))
                    (zero_extract:SI (reg/v:SI 176 [ a ])
                                     (const_int 1 [0x1])
                                     (const_int 3 [0x3])))
             (and:SI (ashift:SI (reg/v:SI 176 [ a ])
                                (const_int 3 [0x3]))
                     (const_int 8 [0x8]))))

A predicate that accepts IOR chains of single bit selections (via zero_extract
or shift-and) could be used to capture the sequence during combine and then
smash it in split1.

Possibly related: PR 65265, PR 63321.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug target/65266] [SH] Use rotcl for bit reversals
  2015-03-01 20:45 [Bug target/65266] New: [SH] Use rotcl for bit reversals olegendo at gcc dot gnu.org
@ 2021-08-28  3:51 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  3:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-28  3:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 20:45 [Bug target/65266] New: [SH] Use rotcl for bit reversals olegendo at gcc dot gnu.org
2021-08-28  3:51 ` [Bug target/65266] " pinskia at gcc dot gnu.org

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).