Skip to content

Commit 2c5c11a

Browse files
committed
Improve configure test for the sse4.2 crc instruction.
With optimizations enabled at least one compiler, clang 3.7, optimized away the crc intrinsics knowing that the result went on unused and has no side effects. That can trigger errors in code generation when the intrinsic is used, as we chose to use the intrinsics without any additional compiler flag. Return the computed value to prevent that. With some more pedantic warning flags (-Wold-style-definition) the configure test failed to recognize the existence of _mm_crc32_u* intrinsics due to an independent warning in the test because the test turned on -Werror, but that's not actually needed here. Discussion: 20150814092039.GH4955@awork2.anarazel.de Backpatch: 9.5, where the use of crc intrinsics was integrated.
1 parent 9a18a2b commit 2c5c11a

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

config/c-compiler.m4

+3-4
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,14 @@ AC_DEFUN([PGAC_SSE42_CRC32_INTRINSICS],
488488
AC_CACHE_CHECK([for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=$1], [Ac_cachevar],
489489
[pgac_save_CFLAGS=$CFLAGS
490490
CFLAGS="$pgac_save_CFLAGS $1"
491-
ac_save_c_werror_flag=$ac_c_werror_flag
492-
ac_c_werror_flag=yes
493491
AC_TRY_LINK([#include <nmmintrin.h>],
494492
[unsigned int crc = 0;
495493
crc = _mm_crc32_u8(crc, 0);
496-
crc = _mm_crc32_u32(crc, 0);],
494+
crc = _mm_crc32_u32(crc, 0);
495+
/* return computed value, to prevent the above being optimized away */
496+
return crc == 0;],
497497
[Ac_cachevar=yes],
498498
[Ac_cachevar=no])
499-
ac_c_werror_flag=$ac_save_c_werror_flag
500499
CFLAGS="$pgac_save_CFLAGS"])
501500
if test x"$Ac_cachevar" = x"yes"; then
502501
CFLAGS_SSE42="$1"

configure

+4-6
Original file line numberDiff line numberDiff line change
@@ -14296,8 +14296,6 @@ if ${pgac_cv_sse42_crc32_intrinsics_+:} false; then :
1429614296
else
1429714297
pgac_save_CFLAGS=$CFLAGS
1429814298
CFLAGS="$pgac_save_CFLAGS "
14299-
ac_save_c_werror_flag=$ac_c_werror_flag
14300-
ac_c_werror_flag=yes
1430114299
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1430214300
/* end confdefs.h. */
1430314301
#include <nmmintrin.h>
@@ -14307,6 +14305,8 @@ main ()
1430714305
unsigned int crc = 0;
1430814306
crc = _mm_crc32_u8(crc, 0);
1430914307
crc = _mm_crc32_u32(crc, 0);
14308+
/* return computed value, to prevent the above being optimized away */
14309+
return crc == 0;
1431014310
;
1431114311
return 0;
1431214312
}
@@ -14318,7 +14318,6 @@ else
1431814318
fi
1431914319
rm -f core conftest.err conftest.$ac_objext \
1432014320
conftest$ac_exeext conftest.$ac_ext
14321-
ac_c_werror_flag=$ac_save_c_werror_flag
1432214321
CFLAGS="$pgac_save_CFLAGS"
1432314322
fi
1432414323
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_sse42_crc32_intrinsics_" >&5
@@ -14336,8 +14335,6 @@ if ${pgac_cv_sse42_crc32_intrinsics__msse4_2+:} false; then :
1433614335
else
1433714336
pgac_save_CFLAGS=$CFLAGS
1433814337
CFLAGS="$pgac_save_CFLAGS -msse4.2"
14339-
ac_save_c_werror_flag=$ac_c_werror_flag
14340-
ac_c_werror_flag=yes
1434114338
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1434214339
/* end confdefs.h. */
1434314340
#include <nmmintrin.h>
@@ -14347,6 +14344,8 @@ main ()
1434714344
unsigned int crc = 0;
1434814345
crc = _mm_crc32_u8(crc, 0);
1434914346
crc = _mm_crc32_u32(crc, 0);
14347+
/* return computed value, to prevent the above being optimized away */
14348+
return crc == 0;
1435014349
;
1435114350
return 0;
1435214351
}
@@ -14358,7 +14357,6 @@ else
1435814357
fi
1435914358
rm -f core conftest.err conftest.$ac_objext \
1436014359
conftest$ac_exeext conftest.$ac_ext
14361-
ac_c_werror_flag=$ac_save_c_werror_flag
1436214360
CFLAGS="$pgac_save_CFLAGS"
1436314361
fi
1436414362
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_sse42_crc32_intrinsics__msse4_2" >&5

0 commit comments

Comments
 (0)