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

mark.dickinson python-checkins at python.org
Wed Apr 15 13:18:35 CEST 2009


Author: mark.dickinson
Date: Wed Apr 15 13:18:34 2009
New Revision: 71614
Log:
Refactor SSE2 detection in configure script, and
link everything up so that we don't try to use
SSE2 instructions on platforms where they don't exist.
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 13:18:34 2009
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 71611 .
+# From configure.in Revision: 71613 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for python 3.1.
 #
@@ -21842,15 +21842,35 @@
 # on modern machines)
 # (2) using inline assembler to get and set the x87 FPU control word
 # otherwise.
+#
+# On AMD64 (aka x86-64), gcc automatically enables use of SSE2
+# instructions, so we don't bother trying to detect.
 
 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
+ # determine whether we're already using the SSE2 instruction set for math
+ # (e.g., this is true by default on OS X/x86)
+ { 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; }
+ if [ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]
+ then
+ ac_sse2_enabled=no
+ else
+ ac_sse2_enabled=yes
+ fi
+ { echo "$as_me:$LINENO: result: $ac_sse2_enabled" >&5
+echo "${ECHO_T}$ac_sse2_enabled" >&6; }
+
+ # if we're not using SSE2 already, we need to either enable it
+ # (when available), or use inline assembler to get and set the
+ # 387 control word.
+ if test $ac_sse2_enabled = no
+ then
+ # Check cpuid for SSE2 availability. 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
+ if test "$cross_compiling" = yes; then
 ac_cv_cpu_has_sse2=no
 else
 cat >conftest.$ac_ext <<_ACEOF
@@ -21860,20 +21880,22 @@
 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;
- }
+ 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)
+ : "cc" );
+ if ((dx & (1U << 25)) && (dx & (1U << 26)))
+ return 0;
+ else
+ return 1;
+ }
 
 _ACEOF
 rm -f conftest$ac_exeext
@@ -21909,24 +21931,10 @@
 fi
 
 
- { echo "$as_me:$LINENO: result: $ac_cv_cpu_has_sse2" >&5
+ { 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; }
- if [ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]
- then
- ac_sse2_enabled=no
- else
- ac_sse2_enabled=yes
- fi
- { echo "$as_me:$LINENO: result: $ac_sse2_enabled" >&5
-echo "${ECHO_T}$ac_sse2_enabled" >&6; }
-
- # if not, try using gcc options to enable it
- if test $ac_sse2_enabled = no
- then
+ # determine whether gcc accepts options to turn on SSE2
 { echo "$as_me:$LINENO: checking whether $CC accepts -msse2 -mfpmath=sse" >&5
 echo $ECHO_N "checking whether $CC accepts -msse2 -mfpmath=sse... $ECHO_C" >&6; }
 ac_save_cc="$CC"
@@ -21979,17 +21987,17 @@
 { echo "$as_me:$LINENO: result: $ac_cv_msse2_ok" >&5
 echo "${ECHO_T}$ac_cv_msse2_ok" >&6; }
 
- if test $ac_cv_msse2_ok = yes
+ if test $ac_cv_cpu_has_sse2 = yes && test $ac_cv_msse2_ok = yes
 then
 BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
 else
+ # SSE2 doesn't appear to be available. Check that it's okay
+ # to use gcc inline assembler to get and set x87 control word
 
 cat >>confdefs.h <<\_ACEOF
 #define USING_X87_FPU 1
 _ACEOF
 
- # SSE2 doesn't appear to be available. Check that it's okay
- # to use gcc inline assembler to get and set x87 control word
 { echo "$as_me:$LINENO: checking whether we can use gcc inline assembler to get and set x87 control word" >&5
 echo $ECHO_N "checking whether we can use gcc inline assembler to get and set x87 control word... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
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 13:18:34 2009
@@ -3157,35 +3157,14 @@
 # on modern machines)
 # (2) using inline assembler to get and set the x87 FPU control word
 # otherwise.
+#
+# On AMD64 (aka x86-64), gcc automatically enables use of SSE2
+# instructions, so we don't bother trying to detect.
 
 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
+ # (e.g., this is true by default on OS X/x86)
 AC_MSG_CHECKING(whether SSE2 instructions are already enabled for math)
 if [[ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]]
 then
@@ -3195,9 +3174,38 @@
 fi
 AC_MSG_RESULT($ac_sse2_enabled)
 
- # if not, try using gcc options to enable it
+ # if we're not using SSE2 already, we need to either enable it
+ # (when available), or use inline assembler to get and set the
+ # 387 control word.
 if test $ac_sse2_enabled = no
 then
+ # Check cpuid for SSE2 availability. 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)
+ : "cc" );
+ if ((dx & (1U << 25)) && (dx & (1U << 26)))
+ 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 gcc accepts options to turn on SSE2
 AC_MSG_CHECKING(whether $CC accepts -msse2 -mfpmath=sse)
 ac_save_cc="$CC"
 CC="$CC -msse2 -mfpmath=sse"
@@ -3208,15 +3216,15 @@
 CC="$ac_save_cc"
 AC_MSG_RESULT($ac_cv_msse2_ok)
 
- if test $ac_cv_msse2_ok = yes
+ if test $ac_cv_cpu_has_sse2 = yes && test $ac_cv_msse2_ok = yes
 then
 BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
 else
+ # SSE2 doesn't appear to be available. Check that it's okay
+ # to use gcc inline assembler to get and set x87 control word
 AC_DEFINE(USING_X87_FPU, 1,
 [Define on x86 hardware if the x87 FPU is being used
 for floating-point arithmetic])
- # SSE2 doesn't appear to be available. Check that it's okay
- # to use gcc inline assembler to get and set x87 control word
 AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
 AC_TRY_COMPILE([], [
 unsigned short cw;
@@ -3227,8 +3235,8 @@
 AC_MSG_RESULT($have_gcc_asm_for_x87)
 if test "$have_gcc_asm_for_x87" = yes
 then
- AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
- [Define if we can use gcc inline assembler to get and set x87 control word])
+ AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
+ [Define if we can use gcc inline assembler to get and set x87 control word])
 fi
 fi
 fi


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /