[Speex-dev] configure patch to check for SSE

Thorvald Natvig thorvald at natvig.com
Thu Apr 3 08:39:54 PDT 2008


The attached patch changes the configure.ac logic as follows:

It tests if the current compiler/cflags combination supports SSE, and if 
so enables _USE_SSE. This can be overridden by the '--enable-sse' and 
'--disable-sse' flags. Using '--enable-sse' will additionally add '-O3 
-msse' to CFLAGS, just as it used to.

I've tested this using the following combinations:
x86_64: ./configure: Detected and used.
x86_64: ./configure --disable-sse: Detected but not used.
i686: ./configure: Not detected.
i686: CFLAGS="-march=pentium3" ./configure: Detected and used.
i686: CFLAGS="-march=pentium2 -msse" ./configure: Detected and used.
i686: CFLAGS="-march=pentium2" ./configure: Not detected, not used.
i686: ./configure --enable-sse: Not detected, still enabled and '-O3 
-msse' added.

In other words, if you've already set up your compiler to produce SSE 
code, we'll use the SSE intrinsics in Speex.
-------------- next part --------------
Index: configure.ac
--- configure.ac	(revision 14652)
+++ configure.ac	(working copy)
@@ -72,6 +72,22 @@
+AC_MSG_CHECKING(for SSE in current arch/CFLAGS)
+#include <xmmintrin.h>
+__m128 testfunc(float *a, float *b) {
+  return _mm_add_ps(_mm_loadu_ps(a), _mm_loadu_ps(b));
 AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
@@ -102,12 +118,19 @@
   AC_DEFINE([ENABLE_VALGRIND], , [Enable valgrind extra checks])
-AC_ARG_ENABLE(sse, [  --enable-sse            Enable SSE support], [if test "$enableval" = yes; then
-AC_DEFINE([_USE_SSE], , [Enable SSE support])
+AC_ARG_ENABLE(sse, [  --enable-sse            Enable SSE support], [
+if test "x$enableval" != xno; then
 CFLAGS="$CFLAGS -O3 -msse"
+if test "$has_sse" = yes; then
+  AC_DEFINE([_USE_SSE], , [Enable SSE support])
 AC_ARG_ENABLE(fixed-point, [  --enable-fixed-point    Compile as fixed-point],
 [if test "$enableval" = yes; then
   AC_DEFINE([FIXED_POINT], , [Compile as fixed-point])

More information about the Speex-dev mailing list