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]

Re: [PATCH] Disable use of FMA instructions in branred


Here is an updated patch, which also removes branred_fma4
(compile-tested only).  I have also moved the CFLAGS setting to
sysdeps/ieee754/dbl-64/Makefile, since that is the location of the
problematic file.

Andreas.

2012-03-17  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.
	* sysdeps/ieee754/dbl-64/Makefile: New file.
	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Remove brandred-fma4.
	(CFLAGS-brandred-fma4.c): Remove.
	* sysdeps/x86_64/fpu/multiarch/brandred-fma4.c: Remove.
	* sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c (__branred): Don't
	define.
	* sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c (__branred): Don't
	define.

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 ee5e856..217854f 100644
--- a/configure.in
+++ b/configure.in
@@ -2000,6 +2000,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
@@ -2144,6 +2154,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/sysdeps/ieee754/dbl-64/Makefile b/sysdeps/ieee754/dbl-64/Makefile
new file mode 100644
index 0000000..953fac7
--- /dev/null
+++ b/sysdeps/ieee754/dbl-64/Makefile
@@ -0,0 +1,4 @@
+ifeq ($(subdir),math)
+# brandred depends on precise IEEE double rounding
+CFLAGS-branred.c = $(config-cflags-nofma)
+endif
diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
index 2a38ffc..12b0526 100644
--- a/sysdeps/x86_64/fpu/multiarch/Makefile
+++ b/sysdeps/x86_64/fpu/multiarch/Makefile
@@ -7,10 +7,9 @@ libm-sysdep_routines += e_exp-fma4 e_log-fma4 e_pow-fma4 s_atan-fma4 \
 			e_asin-fma4 e_atan2-fma4 s_sin-fma4 s_tan-fma4 \
 			mplog-fma4 mpa-fma4 slowexp-fma4 slowpow-fma4 \
 			sincos32-fma4 doasin-fma4 dosincos-fma4 \
-			brandred-fma4 halfulp-fma4 mpexp-fma4 \
+			halfulp-fma4 mpexp-fma4 \
 			mpatan2-fma4 mpatan-fma4 mpsqrt-fma4 mptan-fma4
 
-CFLAGS-brandred-fma4.c = -mfma4
 CFLAGS-doasin-fma4.c = -mfma4
 CFLAGS-dosincos-fma4.c = -mfma4
 CFLAGS-e_asin-fma4.c = -mfma4
diff --git a/sysdeps/x86_64/fpu/multiarch/brandred-fma4.c b/sysdeps/x86_64/fpu/multiarch/brandred-fma4.c
deleted file mode 100644
index f4f68ac..0000000
--- a/sysdeps/x86_64/fpu/multiarch/brandred-fma4.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define __branred __branred_fma4
-#define SECTION __attribute__ ((section (".text.fma4")))
-
-#include <sysdeps/ieee754/dbl-64/branred.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c b/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c
index 2501af9..4c35739 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c
@@ -1,6 +1,5 @@
 #define __cos __cos_fma4
 #define __sin __sin_fma4
-#define __branred __branred_fma4
 #define __docos __docos_fma4
 #define __dubsin __dubsin_fma4
 #define __mpcos __mpcos_fma4
diff --git a/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c b/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c
index d7dab3c..a805440 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c
@@ -1,5 +1,4 @@
 #define tan __tan_fma4
-#define __branred __branred_fma4
 #define __dbl_mp __dbl_mp_fma4
 #define __mpranred __mpranred_fma4
 #define __mptan __mptan_fma4
-- 
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]