On Sat, 8 Dec 2012 15:29:53 +0200 Siarhei Siamashka <siarhei.siamas...@gmail.com> wrote:
> Just use SSE2 intrinsics to do unaligned memory accesses as > a workaround for this gcc bug related to vector extensions. > --- > test/utils-prng.c | 12 ++++++++++++ > 1 files changed, 12 insertions(+), 0 deletions(-) > > diff --git a/test/utils-prng.c b/test/utils-prng.c > index 7c2dd6a..967b898 100644 > --- a/test/utils-prng.c > +++ b/test/utils-prng.c > @@ -27,6 +27,10 @@ > #include "utils.h" > #include "utils-prng.h" > > +#if defined(GCC_VECTOR_EXTENSIONS_SUPPORTED) && defined(__SSE2__) > +#include <xmmintrin.h> > +#endif > + > void smallprng_srand_r (smallprng_t *x, uint32_t seed) > { > uint32_t i; > @@ -77,6 +81,14 @@ store_rand_128_data (void *addr, prng_rand_128_data_t *d, > int aligned) > *(uint8x16 *)addr = d->vb; > return; > } > + else > + { > +#ifdef __SSE2__ > + /* workaround for http://gcc.gnu.org/PR55614 */ > + _mm_storeu_si128 (addr, _mm_loadu_si128 ((__m128i *)d)); > + return; > +#endif > + } > #endif > /* we could try something better for unaligned writes (packed attribute), > * but GCC is not very reliable: http://gcc.gnu.org/PR55454 */ I have pushed this workaround to pixman git repository. However the architectures other than x86 may be affected too. Another possible workaround for glibc based systems seems to be to define _FORTIFY_SOURCE=2 (which is already used by default in gentoo and ubuntu, so they should be unaffected): diff --git a/configure.ac b/configure.ac index 81f068d..2533796 100644 --- a/configure.ac +++ b/configure.ac @@ -184,6 +184,7 @@ AC_SUBST(LT_VERSION_INFO) PIXMAN_CHECK_CFLAG([-Wall]) PIXMAN_CHECK_CFLAG([-fno-strict-aliasing]) +PIXMAN_CHECK_CFLAG([-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2]) dnl ========================================================================= dnl OpenMP for the test suite? Changing "memcpy" to "memmove" should also work, though this makes the code even slower for unaligned buffers. Considering that x86 systems have a workaround, ARM systems are unaffected and linux distros which define _FORTIFY_SOURCE are unaffected too, the chances to encounter this bug should be really low. And in the worst case it may only affect "make check", not the pixman library itself. But surely a fix in the compiler for gcc-4.7.3 would be the best solution. -- Best regards, Siarhei Siamashka _______________________________________________ Pixman mailing list Pixman@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pixman