From 9d465faf92900b572286d6e9701632c2b289b451 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 8 Feb 2012 19:38:17 +0000 Subject: [PATCH] math: Compile with -mfancy-math-387 -funsafe-optimizations on x86. From-SVN: r184015 --- gcc/go/gofrontend/expressions.cc | 3 ++- libgo/Makefile.am | 4 +++- libgo/Makefile.in | 5 ++++- libgo/configure | 32 ++++++++++++++++++++++++++++++-- libgo/configure.ac | 17 +++++++++++++++++ libgo/testsuite/Makefile.in | 1 + 6 files changed, 57 insertions(+), 5 deletions(-) diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 395a37547dd..8357ad75e4e 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -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 diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 3f5bb2ff5b2..b94bc06ac3b 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -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 diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 4aebb2d6fd7..556de688dc7 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -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 diff --git a/libgo/configure b/libgo/configure index 9b65c2519a2..5821d32ab71 100755 --- a/libgo/configure +++ b/libgo/configure @@ -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" diff --git a/libgo/configure.ac b/libgo/configure.ac index 3de5b4a2c8b..155a412ee68 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -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]) diff --git a/libgo/testsuite/Makefile.in b/libgo/testsuite/Makefile.in index c7e35057074..e9269d94863 100644 --- a/libgo/testsuite/Makefile.in +++ b/libgo/testsuite/Makefile.in @@ -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@ -- 2.30.2