[Liboil] alignment problems with sse2
Matthias Drochner
M.Drochner at fz-juelich.de
Tue Oct 24 10:51:48 PDT 2006
While we are here...
After I've updated the liboil package for NetBSD/pkgsrc to 0.3.9 I got reports
that most of the functions in composite_sse_2pix.c and
composite_sse_4pix.c trigger compiler crashes (ICE) on gcc-3.3.3/i386.
(I was using gcc-4.1.x all the time.)
I've disabled SSE2 on i386 anyway, so the easiest workaround was to #ifdef
out the offending code on i386.
amd64 is fine, even with gcc-3.3.3, just that the cpuflags are never read
there, which makes that sse and mmx are not used. If I enable that, the
selftest succeeds. Didn't try real-world applications yet.
I'll append my current set of patches.
best regards
Matthias
-------------- next part --------------
$NetBSD: patch-aa,v 1.2 2006/10/23 18:39:24 drochner Exp $
--- liboil/liboilcpu.c.orig 2006-05-23 02:07:56.000000000 +0200
+++ liboil/liboilcpu.c
@@ -518,6 +518,14 @@ oil_cpu_detect_cpuid (void)
OIL_WARNING("L2 cache: %d kbytes, %d assoc, %d lines/tag, %d line size\n",
(ecx>>16)&0xffff, (ecx>>12)&0xf, (ecx>>8)&0xf, ecx&0xff);
}
+
+#ifdef __i386__
+ /*
+ * gcc (4.1) doesn't get the alignment of automatic __m128i variables
+ * right, leading to GPFs depending on stack alignment on function call.
+ */
+ oil_cpu_flags &= ~(OIL_IMPL_FLAG_SSE2 | OIL_IMPL_FLAG_SSE3);
+#endif
}
/* Reduce the set of CPU capabilities detected by whatever detection mechanism
@@ -542,7 +550,7 @@ oil_cpu_detect_kernel_support (void)
OIL_IMPL_FLAG_MMXEXT | OIL_IMPL_FLAG_SSE3);
}
#endif
-#if !defined(__linux__) && !defined(__FreeBSD__)
+#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
/* If we don't know that the operating system supports SSE, don't trust that
* it will properly support it.
*/
@@ -743,7 +751,7 @@ oil_cpu_detect_mips(void)
static void
oil_cpu_detect_arch(void)
{
-#ifdef __i386__
+#if defined(__i386__) || defined(__amd64__)
oil_cpu_detect_i386();
#endif
#if defined(__powerpc__) || defined(__PPC__) || defined(__ppc__)
-------------- next part --------------
$NetBSD: patch-ab,v 1.1 2006/10/23 18:39:24 drochner Exp $
--- ./liboil/sse/composite_sse_2pix.c.orig 2005-12-21 02:27:54.000000000 +0100
+++ ./liboil/sse/composite_sse_2pix.c
@@ -136,6 +136,13 @@ static __m128i over_argb_sse2(__m128i de
return _mm_adds_epu8(src, muldiv_255_sse2(dest, negate_argb_sse2(srca)));
}
+/*
+ * These functions trigger an ICE with gcc-3.3.3 on i386.
+ * (see NetBSD PR pkg/34886)
+ * Since SSE2 is broken anyway on i386, just disable it.
+ * (amd64 is OK)
+ */
+#ifndef __i386__
static void
composite_in_argb_sse_2pix (uint32_t *dest, const uint32_t *src,
const uint8_t *mask, int n)
@@ -389,6 +396,7 @@ composite_in_over_argb_const_mask_sse_2p
}
OIL_DEFINE_IMPL_FULL (composite_in_over_argb_const_mask_sse_2pix,
composite_in_over_argb_const_mask, OIL_IMPL_FLAG_SSE2);
+#endif
static void
composite_over_u8_sse_2pix (uint8_t *dest, const uint8_t *src, int n)
-------------- next part --------------
$NetBSD: patch-ac,v 1.1 2006/10/23 18:39:24 drochner Exp $
--- ./liboil/sse/composite_sse_4pix.c.orig 2006-10-23 20:03:45.000000000 +0200
+++ ./liboil/sse/composite_sse_4pix.c
@@ -270,6 +270,13 @@ composite_in_argb_const_mask_sse (uint32
OIL_DEFINE_IMPL_FULL (composite_in_argb_const_mask_sse,
composite_in_argb_const_mask, OIL_IMPL_FLAG_SSE2);
+/*
+ * These functions trigger an ICE with gcc-3.3.3 on i386.
+ * (see NetBSD PR pkg/34886)
+ * Since SSE2 is broken anyway on i386, just disable it.
+ * (amd64 is OK)
+ */
+#ifndef __i386__
static void
composite_over_argb_sse (uint32_t *dest, const uint32_t *src, int n)
{
@@ -504,6 +511,7 @@ composite_in_over_argb_const_mask_sse (u
}
OIL_DEFINE_IMPL_FULL (composite_in_over_argb_const_mask_sse,
composite_in_over_argb_const_mask, OIL_IMPL_FLAG_SSE2);
+#endif
static void
composite_over_u8_sse (uint8_t *dest, const uint8_t *src, int n)
More information about the Liboil
mailing list