]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Remove specialized word-length popcount implementations.
authorNathan Bossart <nathan@postgresql.org>
Thu, 12 Feb 2026 17:32:49 +0000 (11:32 -0600)
committerNathan Bossart <nathan@postgresql.org>
Thu, 12 Feb 2026 17:32:49 +0000 (11:32 -0600)
commita4688988835f1f5e607040c8d89e52cbfba9369b
treec2239cbfa5ee0d3c22216b0159bae2e031b03926
parentcb7b2e5e8efb3e5fb08052425cd00f067a56f877
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
src/include/port/pg_bitutils.h
src/port/pg_bitutils.c
src/port/pg_popcount_aarch64.c
src/port/pg_popcount_x86.c