OSDN Git Service

math: Compile with -mfancy-math-387 -funsafe-optimizations on x86.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Feb 2012 19:38:17 +0000 (19:38 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Feb 2012 19:38:17 +0000 (19:38 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184015 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc
libgo/Makefile.am
libgo/Makefile.in
libgo/configure
libgo/configure.ac
libgo/testsuite/Makefile.in

index 395a375..8357ad7 100644 (file)
@@ -10027,7 +10027,8 @@ Call_expression::do_get_tree(Translate_context* context)
 
   // This is to support builtin math functions when using 80387 math.
   tree excess_type = NULL_TREE;
-  if (TREE_CODE(fndecl) == FUNCTION_DECL
+  if (optimize
+      && TREE_CODE(fndecl) == FUNCTION_DECL
       && DECL_IS_BUILTIN(fndecl)
       && DECL_BUILT_IN_CLASS(fndecl) == BUILT_IN_NORMAL
       && nargs > 0
index 3f5bb2f..b94bc06 100644 (file)
@@ -1959,7 +1959,9 @@ log/check: $(CHECK_DEPS)
 math/math.lo.dep: $(go_math_files)
        $(BUILDDEPS)
 math/math.lo: $(go_math_files)
-       $(BUILDPACKAGE)
+       $(MKDIR_P) $(@D)
+       files=`echo $^ | sed -e 's/[^ ]*\.gox//g'`; \
+       $(LTGOCOMPILE) $(MATH_FLAG) -I . -c -fgo-prefix="libgo_$(@D)" -o $@ $$files
 math/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: math/check
index 4aebb2d..556de68 100644 (file)
@@ -390,6 +390,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
+MATH_FLAG = @MATH_FLAG@
 MATH_LIBS = @MATH_LIBS@
 MKDIR_P = @MKDIR_P@
 NET_LIBS = @NET_LIBS@
@@ -4512,7 +4513,9 @@ log/check: $(CHECK_DEPS)
 math/math.lo.dep: $(go_math_files)
        $(BUILDDEPS)
 math/math.lo: $(go_math_files)
-       $(BUILDPACKAGE)
+       $(MKDIR_P) $(@D)
+       files=`echo $^ | sed -e 's/[^ ]*\.gox//g'`; \
+       $(LTGOCOMPILE) $(MATH_FLAG) -I . -c -fgo-prefix="libgo_$(@D)" -o $@ $$files
 math/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: math/check
index 9b65c25..5821d32 100755 (executable)
@@ -604,6 +604,7 @@ LTLIBOBJS
 LIBOBJS
 STRUCT_EPOLL_EVENT_FD_OFFSET
 SIZEOF_STRUCT_EPOLL_EVENT
+MATH_FLAG
 STRINGOPS_FLAG
 HAVE_WAIT4_FALSE
 HAVE_WAIT4_TRUE
@@ -11101,7 +11102,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11104 "configure"
+#line 11105 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11207,7 +11208,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11210 "configure"
+#line 11211 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14707,6 +14708,33 @@ if test "$libgo_cv_c_stringops" = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -mfancy-math-387" >&5
+$as_echo_n "checking whether compiler supports -mfancy-math-387... " >&6; }
+if test "${libgo_cv_c_fancymath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -mfancy-math-387"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int i;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libgo_cv_c_fancymath=yes
+else
+  libgo_cv_c_fancymath=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS=$CFLAGS_hold
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_c_fancymath" >&5
+$as_echo "$libgo_cv_c_fancymath" >&6; }
+MATH_FLAG=
+if test "$libgo_cv_c_fancymath" = yes; then
+  MATH_FLAG="-mfancy-math-387 -funsafe-math-optimizations"
+fi
+
+
 CFLAGS_hold=$CFLAGS
 CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
 ac_fn_c_check_type "$LINENO" "off64_t" "ac_cv_type_off64_t" "$ac_includes_default"
index 3de5b4a..155a412 100644 (file)
@@ -522,6 +522,23 @@ if test "$libgo_cv_c_stringops" = yes; then
 fi
 AC_SUBST(STRINGOPS_FLAG)
 
+dnl For x86 we want to compile the math library with -mfancy-math-387
+dnl -funsafe-math-optimizations so that we can use the builtin
+dnl instructions directly.
+AC_CACHE_CHECK([whether compiler supports -mfancy-math-387],
+[libgo_cv_c_fancymath],
+[CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -mfancy-math-387"
+AC_COMPILE_IFELSE([int i;],
+[libgo_cv_c_fancymath=yes],
+[libgo_cv_c_fancymath=no])
+CFLAGS=$CFLAGS_hold])
+MATH_FLAG=
+if test "$libgo_cv_c_fancymath" = yes; then
+  MATH_FLAG="-mfancy-math-387 -funsafe-math-optimizations"
+fi
+AC_SUBST(MATH_FLAG)
+
 CFLAGS_hold=$CFLAGS
 CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
 AC_CHECK_TYPES([off64_t])
index c7e3505..e9269d9 100644 (file)
@@ -108,6 +108,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
+MATH_FLAG = @MATH_FLAG@
 MATH_LIBS = @MATH_LIBS@
 MKDIR_P = @MKDIR_P@
 NET_LIBS = @NET_LIBS@