aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-08-17 11:15:46 +0200
committerAndres Freund <andres@anarazel.de>2015-08-17 11:15:46 +0200
commit6cf72879e944f32b5b8232541cccd575de797fa4 (patch)
tree284212479c37342d47918d1d9a8d92c84fe09387
parent0e8efed59e7f98f237e90fba20364165f7cc9ba9 (diff)
downloadpostgresql-6cf72879e944f32b5b8232541cccd575de797fa4.tar.gz
postgresql-6cf72879e944f32b5b8232541cccd575de797fa4.zip
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.
-rw-r--r--config/c-compiler.m47
-rwxr-xr-xconfigure10
2 files changed, 7 insertions, 10 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 397e1b03797..9feec0c1086 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -456,15 +456,14 @@ AC_DEFUN([PGAC_SSE42_CRC32_INTRINSICS],
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
-ac_c_werror_flag=yes
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <nmmintrin.h>],
[unsigned int crc = 0;
crc = _mm_crc32_u8(crc, 0);
- crc = _mm_crc32_u32(crc, 0);])],
+ crc = _mm_crc32_u32(crc, 0);
+ /* return computed value, to prevent the above being optimized away */
+ return crc == 0;])],
[Ac_cachevar=yes],
[Ac_cachevar=no])
-ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="$pgac_save_CFLAGS"])
if test x"$Ac_cachevar" = x"yes"; then
CFLAGS_SSE42="$1"
diff --git a/configure b/configure
index ebb5cac31c7..0bed81c2e4a 100755
--- a/configure
+++ b/configure
@@ -14498,8 +14498,6 @@ if ${pgac_cv_sse42_crc32_intrinsics_+:} false; then :
else
pgac_save_CFLAGS=$CFLAGS
CFLAGS="$pgac_save_CFLAGS "
-ac_save_c_werror_flag=$ac_c_werror_flag
-ac_c_werror_flag=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <nmmintrin.h>
@@ -14509,6 +14507,8 @@ main ()
unsigned int crc = 0;
crc = _mm_crc32_u8(crc, 0);
crc = _mm_crc32_u32(crc, 0);
+ /* return computed value, to prevent the above being optimized away */
+ return crc == 0;
;
return 0;
}
@@ -14520,7 +14520,6 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="$pgac_save_CFLAGS"
fi
{ $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 :
else
pgac_save_CFLAGS=$CFLAGS
CFLAGS="$pgac_save_CFLAGS -msse4.2"
-ac_save_c_werror_flag=$ac_c_werror_flag
-ac_c_werror_flag=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <nmmintrin.h>
@@ -14549,6 +14546,8 @@ main ()
unsigned int crc = 0;
crc = _mm_crc32_u8(crc, 0);
crc = _mm_crc32_u32(crc, 0);
+ /* return computed value, to prevent the above being optimized away */
+ return crc == 0;
;
return 0;
}
@@ -14560,7 +14559,6 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="$pgac_save_CFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_sse42_crc32_intrinsics__msse4_2" >&5