[PATCH] D142078: [llvm] Move bit counting functions to bit.h (NFC)

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 20:35:49 PST 2023


kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch provides C++20-style countl_zero, countr_zero, countl_one,
and countl_one in bit.h.  Existing functions like countLeadingZeros
become wrappers around the new functions.

Note that I cannot quite declare countLeadingZeros as:

  template <class T> using countLeadingZeros = countl_zero<T>;

because countl_zero returns int, whereas countLeadingZeros returns
unsigned.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142078

Files:
  llvm/include/llvm/ADT/bit.h
  llvm/include/llvm/Support/MathExtras.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142078.490368.patch
Type: text/x-patch
Size: 10025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230119/712a57f3/attachment.bin>


More information about the llvm-commits mailing list