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