[all-commits] [llvm/llvm-project] 8a1203: [llvm adt] Use `__builtin_bswap16` in `byteswap()`...

Roy Shi via All-commits all-commits at lists.llvm.org
Wed Apr 15 05:17:34 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8a12039aa538b13451b1864e7eafbbe04d58b6f3
      https://github.com/llvm/llvm-project/commit/8a12039aa538b13451b1864e7eafbbe04d58b6f3
  Author: Roy Shi <royitaqi at users.noreply.github.com>
  Date:   2026-04-15 (Wed, 15 Apr 2026)

  Changed paths:
    M llvm/include/llvm/ADT/bit.h

  Log Message:
  -----------
  [llvm adt] Use `__builtin_bswap16` in `byteswap()` when available (#190002)

The 32-bit and 64-bit branch of the code has the same pattern of using
`__builtin_bswapXX` when available (before trying to use
`_byteswap_XXXXX`). But the 16-bit branch doesn't do this (it only tries
to use the latter).

It seems `__builtin_bswap16` is a thing (see
[doc](https://gcc.gnu.org/onlinedocs/gcc/Byte-Swapping-Builtins.html)),
so I wonder if we just forgot to use it in the 16-bit branch.

Adding it and hope it helps (i.e. faster than the default shift-and-or
approach).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list