Re: Using POPCNT and other advanced bit manipulation instructions
От | Tom Lane |
---|---|
Тема | Re: Using POPCNT and other advanced bit manipulation instructions |
Дата | |
Msg-id | 3293.1550246240@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Using POPCNT and other advanced bit manipulation instructions (Alvaro Herrera <alvherre@2ndquadrant.com>) |
Список | pgsql-hackers |
Alvaro Herrera <alvherre@2ndquadrant.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
В списке pgsql-hackers по дате отправления: