Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6cf7287

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 0e8efed commit 6cf7287

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
@@ -456,15 +456,14 @@ AC_DEFUN([PGAC_SSE42_CRC32_INTRINSICS],
456456
AC_CACHE_CHECK([for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=$1], [Ac_cachevar],
457457
[pgac_save_CFLAGS=$CFLAGS
458458
CFLAGS="$pgac_save_CFLAGS $1"
459-
ac_save_c_werror_flag=$ac_c_werror_flag
460-
ac_c_werror_flag=yes
461459
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <nmmintrin.h>],
462460
[unsigned int crc = 0;
463461
crc = _mm_crc32_u8(crc, 0);
464-
crc = _mm_crc32_u32(crc, 0);])],
462+
crc = _mm_crc32_u32(crc, 0);
463+
/* return computed value, to prevent the above being optimized away */
464+
return crc == 0;])],
465465
[Ac_cachevar=yes],
466466
[Ac_cachevar=no])
467-
ac_c_werror_flag=$ac_save_c_werror_flag
468467
CFLAGS="$pgac_save_CFLAGS"])
469468
if test x"$Ac_cachevar" = x"yes"; then
470469
CFLAGS_SSE42="$1"

configure

+4-6
Original file line numberDiff line numberDiff line change
@@ -14498,8 +14498,6 @@ if ${pgac_cv_sse42_crc32_intrinsics_+:} false; then :
1449814498
else
1449914499
pgac_save_CFLAGS=$CFLAGS
1450014500
CFLAGS="$pgac_save_CFLAGS "
14501-
ac_save_c_werror_flag=$ac_c_werror_flag
14502-
ac_c_werror_flag=yes
1450314501
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1450414502
/* end confdefs.h. */
1450514503
#include <nmmintrin.h>
@@ -14509,6 +14507,8 @@ main ()
1450914507
unsigned int crc = 0;
1451014508
crc = _mm_crc32_u8(crc, 0);
1451114509
crc = _mm_crc32_u32(crc, 0);
14510+
/* return computed value, to prevent the above being optimized away */
14511+
return crc == 0;
1451214512
;
1451314513
return 0;
1451414514
}
@@ -14520,7 +14520,6 @@ else
1452014520
fi
1452114521
rm -f core conftest.err conftest.$ac_objext \
1452214522
conftest$ac_exeext conftest.$ac_ext
14523-
ac_c_werror_flag=$ac_save_c_werror_flag
1452414523
CFLAGS="$pgac_save_CFLAGS"
1452514524
fi
1452614525
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_sse42_crc32_intrinsics_" >&5
@@ -14538,8 +14537,6 @@ if ${pgac_cv_sse42_crc32_intrinsics__msse4_2+:} false; then :
1453814537
else
1453914538
pgac_save_CFLAGS=$CFLAGS
1454014539
CFLAGS="$pgac_save_CFLAGS -msse4.2"
14541-
ac_save_c_werror_flag=$ac_c_werror_flag
14542-
ac_c_werror_flag=yes
1454314540
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1454414541
/* end confdefs.h. */
1454514542
#include <nmmintrin.h>
@@ -14549,6 +14546,8 @@ main ()
1454914546
unsigned int crc = 0;
1455014547
crc = _mm_crc32_u8(crc, 0);
1455114548
crc = _mm_crc32_u32(crc, 0);
14549+
/* return computed value, to prevent the above being optimized away */
14550+
return crc == 0;
1455214551
;
1455314552
return 0;
1455414553
}
@@ -14560,7 +14559,6 @@ else
1456014559
fi
1456114560
rm -f core conftest.err conftest.$ac_objext \
1456214561
conftest$ac_exeext conftest.$ac_ext
14563-
ac_c_werror_flag=$ac_save_c_werror_flag
1456414562
CFLAGS="$pgac_save_CFLAGS"
1456514563
fi
1456614564
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_sse42_crc32_intrinsics__msse4_2" >&5

0 commit comments

Comments
 (0)