Re: Using POPCNT and other advanced bit manipulation instructions

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Subject: Re: Using POPCNT and other advanced bit manipulation instructions
Date: 2019-02-13 23:17:09
Message-ID: 20190213231709.GA12159@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-Feb-13, Tom Lane wrote:

> Alvaro Herrera <alvherre(at)2ndquadrant(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira 2019-02-14 00:31:17 Re: proposal: pg_restore --convert-to-text
Previous Message James Sewell 2019-02-13 23:00:01 Re: Reaping Temp tables to avoid XID wraparound