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 20190213221719.GA15976@alvherre.pgsql
Whole thread Raw
In response to Re: Using POPCNT and other advanced bit manipulation instructions  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: Using POPCNT and other advanced bit manipulation instructions  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Using POPCNT and other advanced bit manipulation instructions  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
List pgsql-hackers
On 2019-Feb-13, Alvaro Herrera wrote:

> It definitely is ... plans have changed from using IndexOnly scans to
> Seqscans, which is likely fallout from the visibilitymap_count() change.

I think the problem here is that "unsigned long" is 32 bits in this
machine:
  checking whether long int is 64 bits... no

and we have defined pg_popcount64() like this:

static int
pg_popcount64_sse42(uint64 word)
{
    return __builtin_popcountl(word);
}

so it's counting bits in the lower half of the uint64.

If that's correct, then I think we need something like this patch.  But
it makes me wonder whether we need a configure test for
__builtin_popcountll() and friends.  I wonder if there's any compiler
that implements __builtin_popcountl() but not __builtin_popcountll() ...
and if not, then the test for __builtin_popcountl() should be removed,
and have everything rely on the one for __builtin_popcount().

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

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: subscriptionCheck failures on nightjar
Next
From: Tom Lane
Date:
Subject: Re: Using POPCNT and other advanced bit manipulation instructions