[all-commits] [llvm/llvm-project] fdfb99: [libc++] std::byteswap support for _BitInt(N) (#19...

Xavier Roche via All-commits all-commits at lists.llvm.org
Sat May 30 02:08:27 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fdfb99f6336401e534f611c4b2df5a338e26b997
      https://github.com/llvm/llvm-project/commit/fdfb99f6336401e534f611c4b2df5a338e26b997
  Author: Xavier Roche <xavier.roche at algolia.com>
  Date:   2026-05-30 (Sat, 30 May 2026)

  Changed paths:
    M libcxx/include/__bit/byteswap.h
    M libcxx/test/libcxx/transitive_includes/cxx23.csv
    M libcxx/test/libcxx/transitive_includes/cxx26.csv
    M libcxx/test/std/numerics/bit/byteswap.pass.cpp
    A libcxx/test/std/numerics/bit/byteswap.verify.cpp

  Log Message:
  -----------
  [libc++] std::byteswap support for _BitInt(N) (#196512)

Add a byte-reversal loop fallback for `std::byteswap` when `sizeof(T) >
16`,
so the function works for `_BitInt(N)` with `N > 128` and any future
wider
integer type. Without it, those calls hit `static_assert(sizeof(_Tp) ==
0)`
and fail to compile.

Reject `_BitInt(N)` where `N` is not a multiple of `CHAR_BIT`. The
existing
`__builtin_bswap{16,32,64,128}` paths swap the storage representation
including padding bits, and the resulting value's meaning is
unspecified.
A new `static_assert` catches that case and reports it. Size-1 types are
exempt from the check, since no bytes move there.

Part of the [_BitInt(N) libc++
effort](https://discourse.llvm.org/t/bitint-n-support-in-libc-investigations-possible-improvements-looking-for-guidance/90063).

Assisted-by: Claude (Anthropic)

---------

Co-authored-by: Claude Opus 4.6 <noreply at anthropic.com>



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