Re: pgsql: Fix compiler builtin usage in new pg_bitutils.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Fix compiler builtin usage in new pg_bitutils.c
Date: 2019-02-15 18:50:15
Message-ID: 15861.1550256615@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> Hmm, this should fix the build, but I'm rushing out to lunch -- maybe
> I'm missing something.

> diff --git a/src/port/pg_bitutils.c b/src/port/pg_bitutils.c
> index 97bfcebe4e1..e0198f3ab35 100644
> --- a/src/port/pg_bitutils.c
> +++ b/src/port/pg_bitutils.c
> @@ -90,9 +90,11 @@ pg_popcount_available(void)
> static int
> pg_popcount32_choose(uint32 word)
> {
> +#if defined(HAVE__GET_CPUID) || defined(HAVE__CPUID)
> if (pg_popcount_available())
> pg_popcount32 = pg_popcount32_hw;
> else
> +#endif
> pg_popcount32 = pg_popcount32_builtin;

Meh. I don't see why this entire function should exist if there
is nothing for it to do. I'm inclined to think that somewhere
there needs to be a symbol NEED_POPCOUNT_CHOOSING that is only
enabled if we have all three of HAVE__BUILTIN_POPCOUNT, nonempty
CFLAGS_POPCOUNT, and HAVE__GET_CPUID || HAVE__CPUID. Possibly
we should gate building of pg_bitutils_hwpopcnt.c that way too?
Not much point in building that file if we have no way to figure
out when to use it.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2019-02-15 19:32:55 pgsql: Revert attempts to use POPCNT etc instructions
Previous Message Tom Lane 2019-02-15 18:05:25 pgsql: Refactor index cost estimation functions in view of IndexClause