[Pixman] [PATCH 1/2] configure.ac: Check if the compiler supports GCC vector extensions
Siarhei Siamashka
siarhei.siamashka at gmail.com
Thu Mar 6 22:45:08 PST 2014
The Intel Compiler 14.0.0 claims version GCC 4.7.3 compatibility
via __GNUC__/__GNUC__MINOR__ macros, but does not provide the same
level of GCC vector extensions support as the original GCC compiler:
http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
Which results in the following compilation failure:
In file included from ../test/utils.h(7),
from ../test/utils.c(3):
../test/utils-prng.h(138): error: expression must have integral type
uint32x4 e = x->a - ((x->b << 27) + (x->b >> (32 - 27)));
^
The problem is fixed by doing a special check in configure for
this feature.
---
configure.ac | 18 ++++++++++++++++++
test/utils-prng.c | 10 +++++-----
test/utils-prng.h | 9 ++++-----
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6327972..0339494 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1061,6 +1061,24 @@ fi
AC_MSG_RESULT($support_for_builtin_clz)
+dnl =====================================
+dnl GCC vector extensions
+
+support_for_gcc_vector_extensions=no
+
+AC_MSG_CHECKING(for GCC vector extensions)
+AC_LINK_IFELSE([AC_LANG_SOURCE([[
+unsigned int __attribute__ ((vector_size(16))) e, a, b;
+int main (void) { e = a - ((b << 27) + (b >> (32 - 27))) + 1; return e[0]; }
+]])], support_for_gcc_vector_extensions=yes)
+
+if test x$support_for_gcc_vector_extensions = xyes; then
+ AC_DEFINE([HAVE_GCC_VECTOR_EXTENSIONS], [],
+ [Whether the compiler supports GCC vector extensions])
+fi
+
+AC_MSG_RESULT($support_for_gcc_vector_extensions)
+
dnl ==================
dnl libpng
diff --git a/test/utils-prng.c b/test/utils-prng.c
index 7b32e35..c27b5be 100644
--- a/test/utils-prng.c
+++ b/test/utils-prng.c
@@ -27,7 +27,7 @@
#include "utils.h"
#include "utils-prng.h"
-#if defined(GCC_VECTOR_EXTENSIONS_SUPPORTED) && defined(__SSE2__)
+#if defined(HAVE_GCC_VECTOR_EXTENSIONS) && defined(__SSE2__)
#include <xmmintrin.h>
#endif
@@ -52,7 +52,7 @@ void smallprng_srand_r (smallprng_t *x, uint32_t seed)
*/
void prng_srand_r (prng_t *x, uint32_t seed)
{
-#ifdef GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
int i;
prng_rand_128_data_t dummy;
smallprng_srand_r (&x->p0, seed);
@@ -75,7 +75,7 @@ void prng_srand_r (prng_t *x, uint32_t seed)
static force_inline void
store_rand_128_data (void *addr, prng_rand_128_data_t *d, int aligned)
{
-#ifdef GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
if (aligned)
{
*(uint8x16 *)addr = d->vb;
@@ -120,7 +120,7 @@ randmemset_internal (prng_t *prng,
{
prng_rand_128_r (&local_prng, &t);
prng_rand_128_r (&local_prng, &randdata);
-#ifdef GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
if (flags & RANDMEMSET_MORE_FF)
{
const uint8x16 const_C0 =
@@ -199,7 +199,7 @@ randmemset_internal (prng_t *prng,
}
else
{
-#ifdef GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
const uint8x16 bswap_shufflemask =
{
3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
diff --git a/test/utils-prng.h b/test/utils-prng.h
index 564ffce..f9ae8dd 100644
--- a/test/utils-prng.h
+++ b/test/utils-prng.h
@@ -79,8 +79,7 @@
/*****************************************************************************/
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
-#define GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
typedef uint32_t uint32x4 __attribute__ ((vector_size(16)));
typedef uint8_t uint8x16 __attribute__ ((vector_size(16)));
#endif
@@ -92,7 +91,7 @@ typedef struct
typedef struct
{
-#ifdef GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
uint32x4 a, b, c, d;
#else
smallprng_t p1, p2, p3, p4;
@@ -104,7 +103,7 @@ typedef union
{
uint8_t b[16];
uint32_t w[4];
-#ifdef GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
uint8x16 vb;
uint32x4 vw;
#endif
@@ -134,7 +133,7 @@ prng_rand_r (prng_t *x)
static force_inline void
prng_rand_128_r (prng_t *x, prng_rand_128_data_t *data)
{
-#ifdef GCC_VECTOR_EXTENSIONS_SUPPORTED
+#ifdef HAVE_GCC_VECTOR_EXTENSIONS
uint32x4 e = x->a - ((x->b << 27) + (x->b >> (32 - 27)));
x->a = x->b ^ ((x->c << 17) ^ (x->c >> (32 - 17)));
x->b = x->c + x->d;
--
1.8.3.2
More information about the Pixman
mailing list