Make use of pg_popcount() in more places.
Nathan Bossart <nathan@postgresql.org>
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
| Path | Change | +/− |
|---|---|---|
| src/backend/nodes/bitmapset.c | modified | +7 −22 |
| src/include/lib/radixtree.h | modified | +3 −3 |
Discussion
- refactor architecture-specific popcount code 40 messages · 2026-01-14 → 2026-02-23