]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Remove x86_64 math_private.h asms.
authorJoseph Myers <joseph@codesourcery.com>
Tue, 11 Sep 2018 14:51:40 +0000 (14:51 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 11 Sep 2018 14:51:40 +0000 (14:51 +0000)
The x86_64 math_private.h has asm versions of the macros to
reinterpret between floating-point and integer types.

This is the sort of thing we now strongly discourage; the expectation
in such cases, where the generic C code gives the compiler all the
information needed about the required semantics, is that you should
get the compiler to do the right thing for the generic C code rather
than writing an asm version.

Trivial tests showed GCC generates the expected single instructions
for reinterpretation from floating point to integer.  In the other
direction, it goes via memory when the asms don't; I asked about this
in GCC bug 87236 and was advised this was deliberate for generic
tuning because it was faster that way on some AMD processors (but
-mtune=intel, and -Os with the latest GCC, avoid going via memory).
The asms don't and can't know about those tuning details, so that's
evidence that they are actually making the code worse.

This patch removes the asms accordingly.  Tested for x86_64.

* sysdeps/x86_64/fpu/math_private.h (MOVD): Remove macro.
(MOVQ): Likewise.
(EXTRACT_WORDS64): Likewise.
(INSERT_WORDS64): Likewise.
(GET_FLOAT_WORD): Likewise.
(SET_FLOAT_WORD): Likewise.

ChangeLog
sysdeps/x86_64/fpu/math_private.h

index 7ec115f58860f4a404b82f7c86788c92804d502f..d1aff069dad53737fd27fc2a1fd3f9a6a3eda6c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2018-09-11  Joseph Myers  <joseph@codesourcery.com>
 
+       * sysdeps/x86_64/fpu/math_private.h (MOVD): Remove macro.
+       (MOVQ): Likewise.
+       (EXTRACT_WORDS64): Likewise.
+       (INSERT_WORDS64): Likewise.
+       (GET_FLOAT_WORD): Likewise.
+       (SET_FLOAT_WORD): Likewise.
+
        * scripts/build-many-glibcs.py (Context.__init__): Add full_gcc
        argument.
        (Config.build_gcc): Use --disable-libsanitizer for first GCC
index fcc8537d40c173f9971dc11c5977550108b4628b..306875f92b307683dacae4814ba3102248361d11 100644 (file)
@@ -1,50 +1,6 @@
 #ifndef X86_64_MATH_PRIVATE_H
 #define X86_64_MATH_PRIVATE_H 1
 
-/* We can do a few things better on x86-64.  */
-
-#if defined __AVX__ || defined SSE2AVX
-# define MOVD "vmovd"
-# define MOVQ "vmovq"
-#else
-# define MOVD "movd"
-# define MOVQ "movq"
-#endif
-
-/* Direct movement of float into integer register.  */
-#define EXTRACT_WORDS64(i, d)                                                \
-  do {                                                                       \
-    int64_t i_;                                                                      \
-    asm (MOVQ " %1, %0" : "=rm" (i_) : "x" ((double) (d)));                  \
-    (i) = i_;                                                                \
-  } while (0)
-
-/* And the reverse.  */
-#define INSERT_WORDS64(d, i) \
-  do {                                                                       \
-    int64_t i_ = i;                                                          \
-    double d__;                                                                      \
-    asm (MOVQ " %1, %0" : "=x" (d__) : "rm" (i_));                           \
-    d = d__;                                                                 \
-  } while (0)
-
-/* Direct movement of float into integer register.  */
-#define GET_FLOAT_WORD(i, d) \
-  do {                                                                       \
-    int i_;                                                                  \
-    asm (MOVD " %1, %0" : "=rm" (i_) : "x" ((float) (d)));                   \
-    (i) = i_;                                                                \
-  } while (0)
-
-/* And the reverse.  */
-#define SET_FLOAT_WORD(f, i) \
-  do {                                                                       \
-    int i_ = i;                                                                      \
-    float f__;                                                               \
-    asm (MOVD " %1, %0" : "=x" (f__) : "rm" (i_));                           \
-    f = f__;                                                                 \
-  } while (0)
-
 #include_next <math_private.h>
 
 #ifdef __SSE4_1__