Remove specialized word-length popcount implementations.

Nathan Bossart <nathan@postgresql.org>

Commit: a4688988835f1f5e607040c8d89e52cbfba9369b
Author: Nathan Bossart <nathan@postgresql.org>
Date: 2026-02-12T17:32:49Z
Remove specialized word-length popcount implementations.

The uses of these functions do not justify the level of
micro-optimization we've done and may even hurt performance in some
cases (e.g., due to using function pointers).  This commit removes
all architecture-specific implementations of pg_popcount{32,64} and
converts the portable ones to inlined functions in pg_bitutils.h.
These inlined versions should produce the same code as before (but
inlined), so in theory this is a net gain for many machines.  A
follow-up commit will replace the remaining loops over these
word-length popcount functions with calls to pg_popcount(), further
reducing the need for architecture-specific implementations.

Suggested-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/CANWCAZY7R%2Biy%2Br9YM_sySNydHzNqUirx1xk0tB3ej5HO62GdgQ%40mail.gmail.com

Files

PathChange+/−
src/include/port/pg_bitutils.h modified +51 −24
src/port/pg_bitutils.c modified +2 −63
src/port/pg_popcount_aarch64.c modified +5 −15
src/port/pg_popcount_x86.c modified +1 −42

Discussion