]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix x86_64 -mfpmath=387 float_t, double_t (bug 20787).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 23 Nov 2016 17:56:31 +0000 (17:56 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 23 Nov 2016 17:56:31 +0000 (17:56 +0000)
Bug 20787 reports that, while float_t and double_t for 32-bit x86
properly respect -mfpmath=sse, for x86_64 they fail to reflect
-mfpmath=387, which is valid if unusual and results in FLT_EVAL_METHOD
being 2.  This patch fixes the definitions to respect
__FLT_EVAL_METHOD__ in that case, arranging for the test that the
types correspond with FLT_EVAL_METHOD to be run with both -mfpmath=387
and -mfpmath=sse.

Note: this patch will also have the effect of making float_t and
double_t be long double for x86_64 with -mfpmath=sse+387, when
FLT_EVAL_METHOD is -1.  It seems reasonable for x86_64 to be
consistent with 32-bit x86 in this case (and that definition is
conservatively safe, in that it makes the types correspond to the
widest evaluation format that might be used).

Tested for x86-64 and x86.

[BZ #20787]
* sysdeps/x86/bits/mathdef.h (float_t): Do not define to float if
[__x86_64__] when __FLT_EVAL_METHOD__ is nonzero.
(double_t): Do not define to double if [__x86_64__] when
__FLT_EVAL_METHOD__ is nonzero.
* sysdeps/x86/fpu/test-flt-eval-method-387.c: New file.
* sysdeps/x86/fpu/test-flt-eval-method-sse.c: Likewise.
* sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
test-flt-eval-method-387 and test-flt-eval-method-sse.
[$(subdir) = math] (CFLAGS-test-flt-eval-method-387.c): New
variable.
[$(subdir) = math] (CFLAGS-test-flt-eval-method-sse.c): Likewise.

ChangeLog
sysdeps/x86/bits/mathdef.h
sysdeps/x86/fpu/Makefile
sysdeps/x86/fpu/test-flt-eval-method-387.c [new file with mode: 0644]
sysdeps/x86/fpu/test-flt-eval-method-sse.c [new file with mode: 0644]

index 8dbd8546b6c78ee04fa5274b133363e87fce07ea..963bf2af638ddbe9fc03666317c563587c1d321c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2016-11-23  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #20787]
+       * sysdeps/x86/bits/mathdef.h (float_t): Do not define to float if
+       [__x86_64__] when __FLT_EVAL_METHOD__ is nonzero.
+       (double_t): Do not define to double if [__x86_64__] when
+       __FLT_EVAL_METHOD__ is nonzero.
+       * sysdeps/x86/fpu/test-flt-eval-method-387.c: New file.
+       * sysdeps/x86/fpu/test-flt-eval-method-sse.c: Likewise.
+       * sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
+       test-flt-eval-method-387 and test-flt-eval-method-sse.
+       [$(subdir) = math] (CFLAGS-test-flt-eval-method-387.c): New
+       variable.
+       [$(subdir) = math] (CFLAGS-test-flt-eval-method-sse.c): Likewise.
+
 2016-11-23  Chris Metcalf  <cmetcalf@mellanox.com>
 
        * scripts/build-many-glibcs.py (Context.add_all_configs): Revert
index e61c28aea3fe6f43e2e31ba3d2166239fb5e7443..9423a7f558613a6ee56cc78e05fc06855a9f378b 100644 (file)
@@ -22,7 +22,8 @@
 #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
 # define _MATH_H_MATHDEF       1
 
-# if defined __x86_64__ || (defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 0)
+# if ((defined __x86_64__ && !defined __FLT_EVAL_METHOD__)             \
+      || (defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 0))
 /* The x86-64 architecture computes values with the precission of the
    used type.  Similarly for -m32 -mfpmath=sse.  */
 typedef float float_t;         /* `float' expressions are evaluated as `float'.  */
index b561995658d12823bb4688957130f6693b10cd1a..a8047a4504f9859ffb9d0460325d3be82f73a167 100644 (file)
@@ -1,7 +1,11 @@
 ifeq ($(subdir),math)
 libm-support += powl_helper
-tests += test-fenv-sse test-fenv-clear-sse test-fenv-x87 test-fenv-sse-2
+tests += test-fenv-sse test-fenv-clear-sse test-fenv-x87 test-fenv-sse-2 \
+        test-flt-eval-method-387 test-flt-eval-method-sse
 CFLAGS-test-fenv-sse.c += -msse2 -mfpmath=sse
 CFLAGS-test-fenv-clear-sse.c += -msse2 -mfpmath=sse
 CFLAGS-test-fenv-sse-2.c += -msse2 -mfpmath=sse
+CFLAGS-test-flt-eval-method-387.c += -fexcess-precision=standard -mfpmath=387
+CFLAGS-test-flt-eval-method-sse.c += -fexcess-precision=standard -msse2 \
+                                    -mfpmath=sse
 endif
diff --git a/sysdeps/x86/fpu/test-flt-eval-method-387.c b/sysdeps/x86/fpu/test-flt-eval-method-387.c
new file mode 100644 (file)
index 0000000..2fb7acf
--- /dev/null
@@ -0,0 +1 @@
+#include <test-flt-eval-method.c>
diff --git a/sysdeps/x86/fpu/test-flt-eval-method-sse.c b/sysdeps/x86/fpu/test-flt-eval-method-sse.c
new file mode 100644 (file)
index 0000000..2fb7acf
--- /dev/null
@@ -0,0 +1 @@
+#include <test-flt-eval-method.c>