[all-commits] [llvm/llvm-project] f37614: [llvm] Move bit counting functions to bit.h (NFC)

kazutakahirata via All-commits all-commits at lists.llvm.org
Thu Jan 19 21:15:53 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f37614b25ccaa9c0710cc8a4fc2ba2fb0fcb9159
      https://github.com/llvm/llvm-project/commit/f37614b25ccaa9c0710cc8a4fc2ba2fb0fcb9159
  Author: Kazu Hirata <kazu at google.com>
  Date:   2023-01-19 (Thu, 19 Jan 2023)

  Changed paths:
    M llvm/include/llvm/ADT/bit.h
    M llvm/include/llvm/Support/MathExtras.h
    M llvm/unittests/ADT/BitTest.cpp

  Log Message:
  -----------
  [llvm] Move bit counting functions to bit.h (NFC)

This patch provides C++20-style countl_zero, countr_zero, countl_one,
and countr_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.

Differential Revision: https://reviews.llvm.org/D142078




More information about the All-commits mailing list