[all-commits] [llvm/llvm-project] 42a9c1: [ADT] Add llvm::popcount to <bit> helper wrapper

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Tue Aug 23 02:37:04 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 42a9c1819cb173efb866605186c90a1ab818d46b
      https://github.com/llvm/llvm-project/commit/42a9c1819cb173efb866605186c90a1ab818d46b
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2022-08-23 (Tue, 23 Aug 2022)

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

  Log Message:
  -----------
  [ADT] Add llvm::popcount to <bit> helper wrapper

This patch proposes to move the llvm::detail::PopulationCounter internal helpers into ADT/bit.h and provide a llvm::popcount implementation.

I've left the countPopulation implementation in place in MathExtras.h for now, but updated it to use llvm::popcount.

Hopefully I've got the type_traits correct - I don't use them very often.

Someday we'll move to C++20 with an actual <bit> std header, and we already have this header in place to simplify matters. We'd probably benefit from moving the other <bit> helpers here at some point, but this is a first step.

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




More information about the All-commits mailing list