From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, 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> |
Subject: | Re: Using POPCNT and other advanced bit manipulation instructions |
Date: | 2019-02-15 15:57:20 |
Message-ID: | 3293.1550246240@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> I noticed in Compiler Explorer that some (ancient?) Power cpus
> implement instruction "popcntb", and GCC support for those uses
> -mpopcntb switch enabling __builtin_popcount() to use it. I added the
> switch to configure.in but I'm not sure how well that will work ... I
> don't know if this is represented in buildfarm.
I experimented a bit with this on an old Apple laptop. Apple's
compiler rejects -mpopcntb altogether. FreeBSD's compiler
(gcc 4.2.1) recognizes the switch, but I could not get it to
emit the instruction, even when specifying -mcpu=power5,
which ought to enable it according to the gcc docs:
... The `-mpopcntb' option allows GCC to generate the
popcount and double precision FP reciprocal estimate instruction
implemented on the POWER5 processor and other processors that
support the PowerPC V2.02 architecture.
A more recent gcc info file also mentions
The `-mpopcntd' option
allows GCC to generate the popcount instruction implemented on the
POWER7 processor and other processors that support the PowerPC
V2.06 architecture.
but the gcc version I have on this laptop doesn't know that switch.
In any case, I'm pretty sure Apple never shipped a CPU that could
run either instruction.
I suspect that probing for either option may not be worth the
configure cycles it'd consume :-( ... there are just way too
few of those specific POWER variants out there anymore, even
granting that you have a compiler that will play along.
Moreover, you can't turn on -mpopcntb without having some POWER
equivalent to the CPUID test.
However, if you want to leave the option for this open in
future, it really makes the file name pg_bitutils_sse42.c
quite inappropriate. How about pg_bitutils_hwpopcnt.c
or something like that?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2019-02-15 15:58:40 | Re: Protect syscache from bloating with negative cache entries |
Previous Message | Tomas Vondra | 2019-02-15 15:44:27 | Re: Protect syscache from bloating with negative cache entries |