Re: Using POPCNT and other advanced bit manipulation instructions - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Using POPCNT and other advanced bit manipulation instructions
Date
Msg-id 20190213231709.GA12159@alvherre.pgsql
Whole thread Raw
In response to Re: Using POPCNT and other advanced bit manipulation instructions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2019-Feb-13, Tom Lane wrote:

> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> > and we have defined pg_popcount64() like this:
> 
> > static int
> > pg_popcount64_sse42(uint64 word)
> > {
> >     return __builtin_popcountl(word);
> > }
> 
> That is clearly completely broken.

Pushed my proposed fix, which includes removing the configure tests for
builtins of varying widths.  I couldn't resist sorting entries
alphabetically in configure.in.  (I also used autoheader to produce the
new pg_config.h, which showed me that David had not used it to generate
his diffs there.)

For pg_config.h.win32 I used the compiler explorer tool I just learned
about, and came to the conclusion that MSVC's compiler does not
implement these builtins.

I didn't do anything about the const-cast-away in pg_popcount() yet.
I think that should use PointerIsAligned() instead of what it's doing
now.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: James Sewell
Date:
Subject: Re: Reaping Temp tables to avoid XID wraparound
Next
From: Euler Taveira
Date:
Subject: Re: proposal: pg_restore --convert-to-text