mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-21 03:13:05 +08:00
02a6a54ecd
Test for the compiler builtins __builtin_clz, __builtin_ctz, and __builtin_popcount, and make use of these in preference to handwritten C code if they're available. Create src/port infrastructure for "leftmost one", "rightmost one", and "popcount" so as to centralize these decisions. On x86_64, __builtin_popcount generally won't make use of the POPCNT opcode because that's not universally supported yet. Provide code that checks CPUID and then calls POPCNT via asm() if available. This requires indirecting through a function pointer, which is an annoying amount of overhead for a one-instruction operation, but it's probably not worth working harder than this for our current use-cases. I'm not sure we've found all the existing places that could profit from this new infrastructure; but we at least touched all the ones that used copied-and-pasted versions of the bitmapset.c code, and got rid of multiple copies of the associated constant arrays. While at it, replace c-compiler.m4's one-per-builtin-function macros with a single one that can handle all the cases we need to worry about so far. Also, because I'm paranoid, make those checks into AC_LINK checks rather than just AC_COMPILE; the former coding failed to verify that libgcc has support for the builtin, in cases where it's not inline code. David Rowley, Thomas Munro, Alvaro Herrera, Tom Lane Discussion: https://postgr.es/m/CAKJS1f9WTAGG1tPeJnD18hiQW5gAk59fQ6WK-vfdAKEHyRg2RA@mail.gmail.com |
||
---|---|---|
.. | ||
ac_func_accept_argtypes.m4 | ||
ax_prog_perl_modules.m4 | ||
ax_pthread.m4 | ||
c-compiler.m4 | ||
c-library.m4 | ||
check_decls.m4 | ||
config.guess | ||
config.sub | ||
docbook.m4 | ||
general.m4 | ||
install-sh | ||
libtool.m4 | ||
llvm.m4 | ||
Makefile | ||
missing | ||
perl.m4 | ||
pkg.m4 | ||
prep_buildtree | ||
programs.m4 | ||
python.m4 | ||
tcl.m4 |