mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Optimize pg_comp_crc32c_sse42 routine slightly, and also use it on x86.
Eliminate the separate 'len' variable from the loops, and also use the 4 byte instruction. This shaves off a few more cycles. Even though this routine that uses the special SSE 4.2 instructions is much faster than a generic routine, it's still a hot spot, so let's make it as fast as possible. Change the configure test to not test _mm_crc32_u64. That variant is only available in the 64-bit x86-64 architecture, not in 32-bit x86. Modify pg_comp_crc32c_sse42 so that it only uses _mm_crc32_u64 on x86-64. With these changes, the SSE accelerated CRC-32C implementation can also be used on 32-bit x86 systems. This also fixes the 32-bit MSVC build.
This commit is contained in:
@ -476,12 +476,16 @@ fi])# PGAC_HAVE_GCC__ATOMIC_INT64_CAS
|
||||
|
||||
# PGAC_SSE42_CRC32_INTRINSICS
|
||||
# -----------------------
|
||||
# Check if the compiler supports _mm_crc32_u8 and _mm_crc32_u64 intrinsics.
|
||||
# Check if the compiler supports the x86 CRC instructions added in SSE 4.2,
|
||||
# using the _mm_crc32_u8 and _mm_crc32_u32 intrinsic functions. (We don't
|
||||
# test the 8-byte variant, _mm_crc32_u64, but it is assumed to be present if
|
||||
# the other ones are, on x86-64 platforms)
|
||||
#
|
||||
# An optional compiler flag can be passed as argument (e.g. -msse4.2). If the
|
||||
# intrinsics are supported, sets pgac_sse42_crc32_intrinsics, and CFLAGS_SSE42.
|
||||
AC_DEFUN([PGAC_SSE42_CRC32_INTRINSICS],
|
||||
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_sse42_crc32_intrinsics_$1])])dnl
|
||||
AC_CACHE_CHECK([for _mm_crc32_u8 and _mm_crc32_u64 with CFLAGS=$1], [Ac_cachevar],
|
||||
AC_CACHE_CHECK([for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=$1], [Ac_cachevar],
|
||||
[pgac_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$pgac_save_CFLAGS $1"
|
||||
ac_save_c_werror_flag=$ac_c_werror_flag
|
||||
@ -489,7 +493,7 @@ ac_c_werror_flag=yes
|
||||
AC_TRY_LINK([#include <nmmintrin.h>],
|
||||
[unsigned int crc = 0;
|
||||
crc = _mm_crc32_u8(crc, 0);
|
||||
crc = (unsigned int) _mm_crc32_u64(crc, 0);],
|
||||
crc = _mm_crc32_u32(crc, 0);],
|
||||
[Ac_cachevar=yes],
|
||||
[Ac_cachevar=no])
|
||||
ac_c_werror_flag=$ac_save_c_werror_flag
|
||||
|
Reference in New Issue
Block a user