| 14172 | +# First check if the _mm_crc32_u8 and _mm_crc32_u64 intrinsics can be used | 14173 | 14173 | # with the default compiler flags. If not, check if adding the -msse4.2
|
14174 | 14174 | # flag helps. CFLAGS_SSE42 is set to -msse4.2 if that's required.
|
14175 | 14175 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _mm_crc32_u8 and _mm_crc32_u64 with CFLAGS=" >&5
|
@@ -14254,23 +14254,49 @@ fi
|
14254 | 14254 | fi
|
14255 | 14255 |
|
14256 | 14256 |
|
| 14257 | +# Are we targeting a processor that supports SSE 4.2? gcc, clang and icc all |
| 14258 | +# define __SSE4_2__ in that case. |
| 14259 | +cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
| 14260 | +/* end confdefs.h. */ |
| 14261 | +
|
| 14262 | +int |
| 14263 | +main () |
| 14264 | +{ |
| 14265 | +
|
| 14266 | +#ifndef __SSE4_2__ |
| 14267 | +#error __SSE4_2__ not defined |
| 14268 | +#endif |
| 14269 | +
|
| 14270 | + ;
8000
span> |
| 14271 | + return 0; |
| 14272 | +} |
| 14273 | +_ACEOF |
| 14274 | +if ac_fn_c_try_compile "$LINENO"; then : |
| 14275 | + SSE4_2_TARGETED=1 |
| 14276 | +fi |
| 14277 | +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext |
| 14278 | + |
14257 | 14279 | # Select CRC-32C implementation.
|
14258 | 14280 | #
|
14259 |
| -# If the SSE 4.2 intrinsics are available without extra CFLAGS, then use them |
14260 |
| -# always. If they require extra CFLAGS, compile both implementations and |
14261 |
| -# select which one to use at runtime, depending on whether SSE 4.2 is |
14262 |
| -# supported by the processor we're running on. |
| 14281 | +# If we are targeting a processor that has SSE 4.2 instructions, we can use the |
| 14282 | +# special CRC instructions for calculating CRC-32C. If we're not targeting such |
| 14283 | +# a processor, but we can nevertheless produce code that uses the SSE |
| 14284 | +# intrinsics, perhaps with some extra CFLAGS, compile both implementations and |
| 14285 | +# select which one to use at runtime, depending on whether SSE 4.2 is supported |
| 14286 | +# by the processor we're running on. |
14263 | 14287 | #
|
14264 | 14288 | # You can override this logic by setting the appropriate USE_*_CRC32 flag to 1
|
14265 | 14289 | # in the template or configure command line.
|
14266 | 14290 | if test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_SLICING_BY_8_CRC32C" = x""; then
|
14267 |
| - if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && test x"$CFLAGS_SSE42" = x"" ; then |
| 14291 | + if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && test x"$SSE4_2_TARGETED" = x"1" ; then |
14268 | 14292 | USE_SSE42_CRC32C=1
|
14269 | 14293 | else
|
14270 | 14294 | # the CPUID instruction is needed for the runtime check.
|
14271 | 14295 | if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && (test x"$pgac_cv__get_cpuid" = x"yes" || test x"$pgac_cv__cpuid" = x"yes"); then
|
14272 | 14296 | USE_SSE42_CRC32C_WITH_RUNTIME_CHECK=1
|
14273 | 14297 | else
|
| 14298 | + # fall back to slicing-by-8 algorithm which doesn't require any special |
| 14299 | + # CPU support. |
14274 | 14300 | USE_SLICING_BY_8_CRC32C=1
|
14275 | 14301 | fi
|
14276 | 14302 | fi
|
|
0 commit comments