#bswap
Nanosurprise in #Intel #APX: EVEX encoded reg->reg MOVBE means non-destructive BSWAP!
January 3, 2025 at 5:01 PM
We should be glad x86 has the 'bswap' instruction; it's being really, really useful here; performance wise.
March 5, 2025 at 12:02 AM
@bloodstuck.bsky.social i need to hug bswap nepeta she looks so nice <3
November 18, 2024 at 11:42 AM
On x86 there's a "bswap" instruction that just reverses the bytes in a register.

All good compilers have an intrinsic to use this instruction.

MSVC's intrinsic (_byteswap_ulong) is different in that it's not marked constexpr. :(

std::byteswap is constexpr though.

So this is how they implement it
November 21, 2024 at 10:31 PM
Yet this seems to be the best possible implementation of std::byteswap in MSVC as of present

If they always just do the manual swap, then debug mode builds are better and release mode *sometimes* optimizes it down to a bswap, but often times it doesn't!

The intrinsic MUST be used to ensure a bswap
November 21, 2024 at 10:31 PM
For comparison, this is what the same code looks like in a debug mode build made with GCC (much better):

Ah yes, a bswap.
November 21, 2024 at 10:44 PM
If it's running in a compile-time context, they just do the endian-swap manually.

Otherwise, if it's running in a run-time context, they do the endian-swap via the intrinsic.

This means in release mode builds you get a bswap, but in debug mode builds, you get ABSOLUTELY HORRIBLE assembly:
November 21, 2024 at 10:31 PM
Is MSVC some kind of sick joke
April 8, 2026 at 8:36 AM
charge interactions. Cross-resonance and bSWAP two-qubit gates are implemented, laying the foundation for universal quantum computing. An inter-qubit coupling strength exceeding 60~MHz has been observed, promising fast gate speed and suppressed [3/4 of https://arxiv.org/abs/2503.23738v1]
April 1, 2025 at 6:20 AM
I'm lost in a maze of #bswap helpers all subtly different.
March 19, 2025 at 1:11 PM
ok so there's bswap for htonl. htons? intel suggests, uh, xchg. (like xchg al, ah)

godbolt says gcc 15.1 uses rol at -O3 but xchg at -O1

bswap can even work on 64 bit operands--but not memory operands!!!
May 29, 2025 at 2:58 AM
👤 Post by Bswap (by Members):
"Customizing Notification Templates in SAP Cloud Identity Access Governance (IAG)"
🔗 Link: https://community.sap.com/t5/technology-blog-posts-by-members/customizing-notification-templates-in-sap-cloud-identity-access-governance/ba-p/14342954
March 11, 2026 at 9:39 AM