]> granicus.if.org Git - postgresql/commit
Use Intel SSE 4.2 CRC instructions where available.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 14 Apr 2015 14:05:03 +0000 (17:05 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 14 Apr 2015 14:05:03 +0000 (17:05 +0300)
commit3dc2d62d0486325bf263655c2d9a96aee0b02abe
tree47336185d9126f14d8a3943503706023d05fe4b7
parent4f700bcd20c087f60346cb8aefd0e269be8e2157
Use Intel SSE 4.2 CRC instructions where available.

Modern x86 and x86-64 processors with SSE 4.2 support have special
instructions, crc32b and crc32q, for calculating CRC-32C. They greatly
speed up CRC calculation.

Whether the instructions can be used or not depends on the compiler and the
target architecture. If generation of SSE 4.2 instructions is allowed for
the target (-msse4.2 flag on gcc and clang), use them. If they are not
allowed by default, but the compiler supports the -msse4.2 flag to enable
them, compile just the CRC-32C function with -msse4.2 flag, and check at
runtime whether the processor we're running on supports it. If it doesn't,
fall back to the slicing-by-8 algorithm. (With the common defaults on
current operating systems, the runtime-check variant is what you get in
practice.)

Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.
config/c-compiler.m4
configure
configure.in
src/Makefile.global.in
src/include/pg_config.h.in
src/include/pg_config.h.win32
src/include/port/pg_crc32c.h
src/port/Makefile
src/port/pg_crc32c_choose.c [new file with mode: 0644]
src/port/pg_crc32c_sse42.c [new file with mode: 0644]
src/tools/msvc/Mkvcbuild.pm