On Wed, 17 Dec 2025 at 20:36, Jakub Jelinek <[email protected]> wrote:
>
> On Wed, Dec 17, 2025 at 08:31:58PM +0000, Jonathan Wakely wrote:
> > > So, if you want to use something like popcount, then you need some
> > > function template which for normal unsigned integrals will return
> > > __builtin_popcountg on the argument and for struct __rand_uint128 will
> > > return __builtin_popcountg(_M_hi) + __builtin_popcountg(_M_lo);
> >
> > Do we need popcount at all? Isn't it just sizeof(_UInt) * CHAR_BIT?
>
> If we are just talking about uint32_t, uint64_t, unsigned __int128
> and this struct { uint64_t _M_hi, _M_lo; }; then I guess
> sizeof(_UInt) * __CHAR_BIT__ would be good enough.
> For arbitrary unsigned integral types of course not, whether it
> is unsigned _BitInt(125) or unsigned __int20 etc.

The function is only called by the library, not by users with arbitrary types.

With this patch, the only types it's used with are the ones that
_Select_uint_least_t uses, which means:
unsigned
unsigned long
unsigned long long
unsigned __int128 or __rand_uint128 (depending on the target)

There are no other types used to instantiate the function.

Reply via email to