public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/108938] New: Missing bswap detection
@ 2023-02-27  2:51 crazylht at gmail dot com
  2023-02-27  8:11 ` [Bug target/108938] " jakub at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: crazylht at gmail dot com @ 2023-02-27  2:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108938
           Summary: Missing bswap detection
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

This is the x86 version of this bug.


+++ This bug was initially created as a clone of Bug #108874 +++


If we look at the arm testcases in gcc.target/arm/rev16.c
typedef unsigned int __u32;

__u32
__rev16_32_alt (__u32 x)
{
  return (((__u32)(x) & (__u32)0xff00ff00UL) >> 8)
         | (((__u32)(x) & (__u32)0x00ff00ffUL) << 8);
}

__u32
__rev16_32 (__u32 x)
{
  return (((__u32)(x) & (__u32)0x00ff00ffUL) << 8)
         | (((__u32)(x) & (__u32)0xff00ff00UL) >> 8);
}

we should be able to generate bswap instructions for x86

GCC fails to do so and generates:
__rev16_32_alt(unsigned int):
        mov     eax, edi
        sal     edi, 8
        shr     eax, 8
        and     edi, -16711936
        and     eax, 16711935
        or      eax, edi
        ret
__rev16_32(unsigned int):
        mov     eax, edi
        shr     edi, 8
        sal     eax, 8
        and     edi, 16711935
        and     eax, -16711936
        or      eax, edi
        ret

whereas clang manages to recognise it all into:

__rev16_32_alt(unsigned int):                    # @__rev16_32_alt(unsigned
int)
        mov     eax, edi
        bswap   eax
        ror     eax, 16
        ret
__rev16_32(unsigned int):                        # @__rev16_32(unsigned int)
        mov     eax, edi
        bswap   eax
        ror     eax, 16
        ret

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

end of thread, other threads:[~2023-05-30 23:19 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27  2:51 [Bug target/108938] New: Missing bswap detection crazylht at gmail dot com
2023-02-27  8:11 ` [Bug target/108938] " jakub at gcc dot gnu.org
2023-02-27  8:39 ` crazylht at gmail dot com
2023-02-27  9:01 ` jakub at gcc dot gnu.org
2023-02-27  9:40 ` jakub at gcc dot gnu.org
2023-03-06  9:52 ` crazylht at gmail dot com
2023-03-06  9:56 ` jakub at gcc dot gnu.org
2023-03-06  9:57 ` crazylht at gmail dot com
2023-03-06 10:05 ` crazylht at gmail dot com
2023-03-06 10:09 ` jakub at gcc dot gnu.org
2023-03-06 10:41 ` rguenth at gcc dot gnu.org
2023-03-07  2:52 ` crazylht at gmail dot com
2023-03-07  8:40 ` jakub at gcc dot gnu.org
2023-03-07  8:53 ` crazylht at gmail dot com
2023-03-09  2:21 ` crazylht at gmail dot com
2023-03-09  5:50 ` crazylht at gmail dot com
2023-03-10 17:54 ` pinskia at gcc dot gnu.org
2023-05-30  9:54 ` cvs-commit at gcc dot gnu.org
2023-05-30 23:19 ` crazylht at gmail dot com

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