[PATCH] D114425: [clang] Add __builtin_bswap128

Nikolas Klauser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 2 06:17:33 PST 2022


philnik added a comment.

In D114425#3216233 <https://reviews.llvm.org/D114425#3216233>, @xbolva00 wrote:

> int num = …;
>
> __builtin_bswap64(num); // works, no error
> __builtin_bswap128(num); // should work as well
>
> Highly likely this case works already with ur patch, so it would be great to add a test for this scenario.

This should already be tested, because `0x1234` is an `int` and should be implicitly converted to `__int128`.

The question was about the scenario where clang doesn't support `__int128`. 
`__builtin_bswap128()` returns an `unsigned __int128`. This would allow someone to do weird stuff like:

  using int128 = decltype(__builtin_bswap128(0));
  static_assert(sizeof(int128) == 16);

This actually works with the current patch and doesn't seem like it should work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114425/new/

https://reviews.llvm.org/D114425



More information about the cfe-commits mailing list