[Mesa-dev] [PATCH] gallium/util: add util_bitcount64

Ilia Mirkin imirkin at alum.mit.edu
Tue Sep 30 10:17:12 PDT 2014


On Tue, Sep 30, 2014 at 1:14 PM, Tom Stellard <tom at stellard.net> wrote:
> On Tue, Sep 30, 2014 at 12:29:52PM -0400, Ilia Mirkin wrote:
>> Perhaps do the same thing as util_bitcount, i.e.
>>
>> #if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 304)
>>   return __builtin_popcountll(n);
>> #else
>> ...
>> #endif
>>
>> Perhaps the gcc version check is no longer necessary, unlikely
>> anyone's using gcc3.3 or earlier at this point. But whatever.
>>
>
> I saw a patch from Matt recently that added autoconf checks for a bunch
> of different builtin functions, I think we should use those instead.

That sounds way better, but these version checks are all over u_math.h
-- feels like a separate cleanup, not necessary to saddle this simple
change with working out how autoconf works :) But if Marek wants to do
it, I won't object...

>
> -Tom
>
>> On Tue, Sep 30, 2014 at 12:26 PM, Marek Olšák <maraeo at gmail.com> wrote:
>> > From: Marek Olšák <marek.olsak at amd.com>
>> >
>> > I'll need this in radeonsi.
>> > ---
>> >  src/gallium/auxiliary/util/u_math.h | 8 ++++++++
>> >  1 file changed, 8 insertions(+)
>> >
>> > diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
>> > index 39bd40f..48d5c31 100644
>> > --- a/src/gallium/auxiliary/util/u_math.h
>> > +++ b/src/gallium/auxiliary/util/u_math.h
>> > @@ -727,6 +727,14 @@ util_bitcount(unsigned n)
>> >  #endif
>> >  }
>> >
>> > +
>> > +static INLINE unsigned
>> > +util_bitcount64(uint64_t n)
>> > +{
>> > +       return util_bitcount(n) + util_bitcount(n >> 32);
>> > +}
>> > +
>> > +
>> >  /**
>> >   * Reverse bits in n
>> >   * Algorithm taken from:
>> > --
>> > 1.9.1
>> >
>> > _______________________________________________
>> > mesa-dev mailing list
>> > mesa-dev at lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list