Make use of pg_popcount() in more places.

Nathan Bossart <nathan@postgresql.org>

Commit: f33b8793fd7306b81e8c614718ee8f01b4fa0cfd
Author: Nathan Bossart <nathan@postgresql.org>
Date: 2026-02-23T15:26:00Z
Make use of pg_popcount() in more places.

This replaces some loops over word-length popcount functions with
calls to pg_popcount().  Since pg_popcount() may use a function
pointer for inputs with sizes >= a Bitmapset word, this produces a
small regression for the common one-word case in bms_num_members().
To deal with that, this commit adds an inlined fast-path for that
case.  This fast-path could arguably go in pg_popcount() itself
(with an appropriate alignment check), but that is left for future
study.

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

Files

PathChange+/−
src/backend/nodes/bitmapset.c modified +7 −22
src/include/lib/radixtree.h modified +3 −3

Discussion