From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>
Subject: Re: Using POPCNT and other advanced bit manipulation instructions
Date: Wed, 13 Feb 2019 20:17:09 -0300
Message-ID: <20190213231709.GA12159@alvherre.pgsql> (raw)
In-Reply-To: <26998.1550097202@sss.pgh.pa.us>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, tgl@sss.pgh.pa.us, andrew@tao11.riddles.org.uk, david.rowley@2ndquadrant.com, pgsql-hackers@lists.postgresql.org, thomas.munro@enterprisedb.com
Subject: Re: Using POPCNT and other advanced bit manipulation instructions
In-Reply-To: <20190213231709.GA12159@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox