[libc-commits] [PATCH] D132184: [libc] add division to UInt
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Aug 19 08:01:59 PDT 2022
lntue added inline comments.
================
Comment at: libc/src/__support/CPP/UInt.h:41
+ // Construct a UInt from a C array.
+ template <size_t N> constexpr UInt(const uint64_t (&nums)[N]) {
+ size_t min_wordcount = N > WordCount ? N : WordCount;
----------------
sivachandra wrote:
> Not sure if there is a need to initialize from a bigger array. If not, can we restrict this constructor with `enable_if`?
I think a better option that you're looking for is an implicit constructors / assignment from `UInt<M>` to `UInt<N>` with `M <= N`
================
Comment at: libc/src/__support/CPP/UInt.h:286-287
+ UInt<Bits> subtractor = other;
+ for (; static_cast<unsigned>(curBit) < Bits && subtractor < *this &&
+ subtractor << 1 > subtractor;
+ ++curBit, subtractor.shift_left(1)) {
----------------
sivachandra wrote:
> This expression is a bit complicated to parse. Can you put it in a lambda function?
Will it be easier if we implement `clz` for `UInt<N>`? So that we can just make a single shift?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132184/new/
https://reviews.llvm.org/D132184
More information about the libc-commits
mailing list