This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Disable use of FMA instructions in branred


__branred depends on precise double precision, and falls down completely
if the compiler is allowed to contract floating-point expressions (which
is does by default).

Andreas.

2012-03-16  Andreas Schwab  <schwab@linux-m68k.org>

	* configure.in (libc_cv_cc_nofma): Check for option to disable
	generation of FMA instructions.
	* configure: Regenerate.
	* config.make.in (config-cflags-nofma): Set from libc_cv_cc_nofma.
	* math/Makefile (CFLAGS-branred.c): Define.
---
 config.make.in |    1 +
 configure      |   27 +++++++++++++++++++++++++++
 configure.in   |   11 +++++++++++
 math/Makefile  |    1 +
 4 files changed, 40 insertions(+)

diff --git a/config.make.in b/config.make.in
index 2b9a939..54e8393 100644
--- a/config.make.in
+++ b/config.make.in
@@ -38,6 +38,7 @@ config-cflags-sse4 = @libc_cv_cc_sse4@
 config-cflags-avx = @libc_cv_cc_avx@
 config-cflags-sse2avx = @libc_cv_cc_sse2avx@
 config-cflags-novzeroupper = @libc_cv_cc_novzeroupper@
+config-cflags-nofma = @libc_cv_cc_nofma@
 config-asflags-i686 = @libc_cv_as_i686@
 
 defines = @DEFINES@
diff --git a/configure.in b/configure.in
index 119d5be..3c34383 100644
--- a/configure.in
+++ b/configure.in
@@ -2006,6 +2006,16 @@ if test "$libc_cv_gcc_tls_model_attr" = no; then
   AC_MSG_ERROR([support for the tls_model attribute is required])
 fi
 
+dnl Determine how to disable generation of FMA instructions.
+AC_CACHE_CHECK([for option to disable generation of FMA instructions],
+	       libc_cv_cc_nofma, [dnl
+libc_cv_cc_nofma=
+if AC_TRY_COMMAND([${CC-cc} -ffp-contract=off -xc /dev/null -S -o /dev/null]); then
+  libc_cv_cc_nofma=-ffp-contract=off
+elif AC_TRY_COMMAND([${CC-cc} -mno-fused-madd -xc /dev/null -S -o /dev/null]); then
+  libc_cv_cc_nofma=-mno-fused-madd
+fi])
+
 if test -n "$submachine"; then
   AC_CACHE_CHECK([for compiler option for CPU variant],
 		 libc_cv_cc_submachine, [dnl
@@ -2150,6 +2160,7 @@ AC_SUBST(libc_cv_cc_avx)
 AC_SUBST(libc_cv_cc_sse2avx)
 AC_SUBST(libc_cv_cc_novzeroupper)
 AC_SUBST(libc_cv_cc_fma4)
+AC_SUBST(libc_cv_cc_nofma)
 AC_SUBST(libc_cv_as_i686)
 AC_SUBST(libc_cv_sparc_as_vis3)
 
diff --git a/math/Makefile b/math/Makefile
index 3a671aa..a770b6b 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -133,6 +133,7 @@ CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
 			 -DTEST_FAST_MATH -fno-builtin
 CPPFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
 			  -DTEST_FAST_MATH -fno-builtin
+CFLAGS-branred.c = $(config-cflags-nofma)
 
 
 # The -lieee module sets the _LIB_VERSION_ switch to IEEE mode
-- 
1.7.9.4


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]