On 2019-Feb-14, Tom Lane wrote:
> I think we need a clean test for __builtin_popcount(), and to be willing
> to use it if available, independently of -mpopcnt. Then separately we
> should test to see if -mpopcnt works, probably with the same
> infrastructure we use for checking for other compiler flags, viz
>
> # Optimization flags for specific files that benefit from vectorization
> PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
> PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
> + # Optimization flags for bit-twiddling
> + PGAC_PROG_CC_VAR_OPT(CFLAGS_POPCNT, [-mpopcnt])
> # We want to suppress clang's unhelpful unused-command-line-argument warnings
>
> Then the correct test to see if we want to build pg_popcount.c (BTW,
> please pick a less generic name for that) and the choose function
> is whether we have *both* HAVE__BUILTIN_POPCOUNT and nonempty
> CFLAGS_POPCNT.
Yeah, this works. I'll post the patch tomorrow.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services