diff options
author | Nathan Bossart <nathan@postgresql.org> | 2024-03-19 14:46:16 -0500 |
---|---|---|
committer | Nathan Bossart <nathan@postgresql.org> | 2024-03-19 14:46:16 -0500 |
commit | cc4826dd5e52c8af7069feb49ce3cd9358fa6a6e (patch) | |
tree | 5ed611dd4a0a61ed48590159040dd571c30c82df /src/include/port/pg_bitutils.h | |
parent | b7e2121ab7d6166b835a46ceaab1b6a6dc589703 (diff) |
Inline pg_popcount{32,64} into pg_popcount().
On some systems, calls to pg_popcount{32,64} are indirected through
a function pointer. This commit converts pg_popcount() to a
function pointer on those systems so that we can inline the
appropriate pg_popcount{32,64} implementations into each of the
pg_popcount() implementations. Since pg_popcount() may call
pg_popcount{32,64} several times, this can significantly improve
its performance.
Suggested-by: David Rowley
Reviewed-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvrb7MJRB6JuKLDEY2x_LKdFHwVbogpjZBCX547i5%2BrXOQ%40mail.gmail.com
Diffstat (limited to 'src/include/port/pg_bitutils.h')
-rw-r--r-- | src/include/port/pg_bitutils.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/include/port/pg_bitutils.h b/src/include/port/pg_bitutils.h index 46bf4f01038..53e52397170 100644 --- a/src/include/port/pg_bitutils.h +++ b/src/include/port/pg_bitutils.h @@ -302,17 +302,16 @@ pg_ceil_log2_64(uint64 num) /* Attempt to use the POPCNT instruction, but perform a runtime check first */ extern PGDLLIMPORT int (*pg_popcount32) (uint32 word); extern PGDLLIMPORT int (*pg_popcount64) (uint64 word); +extern PGDLLIMPORT uint64 (*pg_popcount) (const char *buf, int bytes); #else /* Use a portable implementation -- no need for a function pointer. */ extern int pg_popcount32(uint32 word); extern int pg_popcount64(uint64 word); +extern uint64 pg_popcount(const char *buf, int bytes); #endif /* TRY_POPCNT_FAST */ -/* Count the number of one-bits in a byte array */ -extern uint64 pg_popcount(const char *buf, int bytes); - /* * Rotate the bits of "word" to the right/left by n bits. */ |