[Python-checkins] r71613 - in python/branches/py3k-short-float-repr: configure configure.in

mark.dickinson python-checkins at python.org
Wed Apr 15 12:38:36 CEST 2009


Author: mark.dickinson
Date: Wed Apr 15 12:38:35 2009
New Revision: 71613

Log:
Add autoconf test that uses the cpuid instruction to detect
whether the CPU supports SSE/SSE2, for gcc/x86.


Modified:
   python/branches/py3k-short-float-repr/configure
   python/branches/py3k-short-float-repr/configure.in

Modified: python/branches/py3k-short-float-repr/configure
==============================================================================
--- python/branches/py3k-short-float-repr/configure	(original)
+++ python/branches/py3k-short-float-repr/configure	Wed Apr 15 12:38:35 2009
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 71602 .
+# From configure.in Revision: 71611 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for python 3.1.
 #
@@ -21845,6 +21845,73 @@
 
 if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
 then
+    # try using cpuid instruction to see whether SSE2 instructions are
+    # available.  Bits 25 and 26 of edx tell us about SSE and SSE2
+    # respectively.
+    { echo "$as_me:$LINENO: checking whether SSE2 instructions are available on this CPU" >&5
+echo $ECHO_N "checking whether SSE2 instructions are available on this CPU... $ECHO_C" >&6; }
+    if test "$cross_compiling" = yes; then
+  ac_cv_cpu_has_sse2=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        int main() {
+            unsigned int ax, bx, cx, dx, func;
+            func = 1U;
+            __asm__ __volatile__ ("pushl %%ebx\n\t"  /* don't clobber ebx */
+                                  "cpuid\n\t"
+                                  "movl %%ebx, %1\n\t"
+                                  "popl %%ebx"
+                                  : "=a" (ax), "=r" (bx), "=c" (cx), "=d" (dx)
+                                  : "a" (func));
+                    if ((dx & (1U << 26)) && (dx & (1U << 25)))
+                return 0;
+            else
+                return 1;
+        }
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_cpu_has_sse2=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_cpu_has_sse2=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+    { echo "$as_me:$LINENO: result: $ac_cv_cpu_has_sse2" >&5
+echo "${ECHO_T}$ac_cv_cpu_has_sse2" >&6; }
+
     # determine whether we're already using the SSE2 instruction set for math
     { echo "$as_me:$LINENO: checking whether SSE2 instructions are already enabled for math" >&5
 echo $ECHO_N "checking whether SSE2 instructions are already enabled for math... $ECHO_C" >&6; }

Modified: python/branches/py3k-short-float-repr/configure.in
==============================================================================
--- python/branches/py3k-short-float-repr/configure.in	(original)
+++ python/branches/py3k-short-float-repr/configure.in	Wed Apr 15 12:38:35 2009
@@ -3160,6 +3160,31 @@
 
 if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
 then
+    # try using cpuid instruction to see whether SSE2 instructions are
+    # available.  Bits 25 and 26 of edx tell us about SSE and SSE2
+    # respectively.
+    AC_MSG_CHECKING(whether SSE2 instructions are available on this CPU)
+    AC_TRY_RUN([
+        int main() {
+            unsigned int ax, bx, cx, dx, func;
+            func = 1U;
+            __asm__ __volatile__ ("pushl %%ebx\n\t"  /* don't clobber ebx */
+                                  "cpuid\n\t"
+                                  "movl %%ebx, %1\n\t"
+                                  "popl %%ebx"
+                                  : "=a" (ax), "=r" (bx), "=c" (cx), "=d" (dx)
+                                  : "a" (func));
+                    if ((dx & (1U << 26)) && (dx & (1U << 25)))
+                return 0;
+            else
+                return 1;
+        }
+    ],
+    ac_cv_cpu_has_sse2=yes,
+    ac_cv_cpu_has_sse2=no,
+    ac_cv_cpu_has_sse2=no)
+    AC_MSG_RESULT($ac_cv_cpu_has_sse2)
+
     # determine whether we're already using the SSE2 instruction set for math
     AC_MSG_CHECKING(whether SSE2 instructions are already enabled for math)
     if [[ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]]


More information about the Python-checkins mailing list