[PATCH] D132407: [ADT] Add llvm::ctpop to <bit> helper wrapper

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 14:00:02 PDT 2022


dblaikie added a comment.

In D132407#3740646 <https://reviews.llvm.org/D132407#3740646>, @RKSimon wrote:

> In D132407#3740594 <https://reviews.llvm.org/D132407#3740594>, @tschuett wrote:
>
>> clang also supports __builtin_popcount:
>> https://clang.llvm.org/docs/LanguageExtensions.html
>
> Yeah - its just a copy + paste from MathExtras.h so far - I'll add a __has_builtin()

Does it help? Or can LLVM pretty reliably optimize the code down to the same thing anyway? (be nice to avoid maintaining the different codepaths if they amount to the same thing anyway)

Looks like at least here clang uses the same code in either case (but doesn't use a CPU intrinsic, whereas GCC does (but GCC doesn't optimize the non-intrinsic code into the intrinsic...)): https://godbolt.org/z/G5YM4bcM6 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132407



More information about the llvm-commits mailing list