Re: [PATCH v2 4/6] bswap.h: Always overwrite ntohl/ ntohll macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2025-06-11 at 22:14:40, Sebastian Andrzej Siewior wrote:
> The ntohl and htonl macros are redefined because the provided macros were
> not always optimal. Sometimes it was a function call, sometimes it was a
> macro which did the shifting. Using the 'bswap' opcode on x86 provides
> probably better performance than performing the shifting.

I believe that the peephole optimizer will almost always optimize them
to the bswap or equivalent opcode, much like it recognizes how to
generate rotate opcodes from two shifts and an or, so they should
actually be equivalent.

GCC and clang both emit simple bswap instructions with `-O2`, which is
the optimization level we use: https://godbolt.org/z/1r8P1Pqo7.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux