]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Remove uses of popcount builtins.
authorNathan Bossart <nathan@postgresql.org>
Mon, 23 Feb 2026 15:26:00 +0000 (09:26 -0600)
committerNathan Bossart <nathan@postgresql.org>
Mon, 23 Feb 2026 15:26:00 +0000 (09:26 -0600)
commiteb9ab7e0930aef9fe1da4b71d0979ebe5361ee48
tree1b542431cab45d5683da33380f5d39e86b23432f
parentb9278871f991e0c1419b96b7508fe5206903fb1a
Remove uses of popcount builtins.

This commit replaces the implementations of pg_popcount{32,64} with
branchless ones in plain C.  While these new implementations do not
make use of more sophisticated population count instructions
available on some CPUs, testing indicates they perform well,
especially now that they are inlined.  Newer versions of popular
compilers will automatically replace these with special
instructions if possible, anyway.  A follow-up commit will replace
various loops over these functions with calls to pg_popcount(),
leaving us little reason to worry about micro-optimizing them
further.

Since this commit removes the only uses of the popcount builtins,
we can also remove the corresponding configuration checks.

Suggested-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/CANWCAZY7R%2Biy%2Br9YM_sySNydHzNqUirx1xk0tB3ej5HO62GdgQ%40mail.gmail.com
configure
configure.ac
meson.build
src/include/pg_config.h.in
src/include/port/pg_bitutils.h
src/port/pg_popcount_aarch64.c