]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Use sign as double for reduced case in sinf
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 5 Dec 2017 17:27:03 +0000 (15:27 -0200)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 5 Dec 2017 18:27:44 +0000 (16:27 -0200)
This patch avoid an extra floating point to integer conversion in
reduced internal function for generic sinf by defining the sign as
double instead of integers.

There is no much difference on Haswell with GCC 7.2.1:

           Before        After
min          9.11        9.108
mean       21.982      21.9224

However H.J. Lu reported gains on Skylake:

Before:

  "sinf": {
   "": {
    "duration": 3.4044e+10,
    "iterations": 1.9942e+09,
    "max": 141.106,
    "min": 7.704,
    "mean": 17.0715
   }
  }

After:

  "sinf": {
   "": {
    "duration": 3.40665e+10,
    "iterations": 2.03199e+09,
    "max": 95.994,
    "min": 7.704,
    "mean": 16.765
   }
  }

Checked on x86_64-linux-gnu.

* sysdeps/ieee754/flt-32/s_sinf.c (ones): Define as double.
(reduced): Use ones as double instead of integer.

ChangeLog
sysdeps/ieee754/flt-32/s_sinf.c

index 15da4e7937ec9973fdd23e0b6a858e5060cf3e9f..bac6b8cb1fe46b07199f5be2ea8feba079dd434a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-05  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       * sysdeps/ieee754/flt-32/s_sinf.c (ones): Define as double.
+       (reduced): Use ones as double instead of integer.
+
 2017-12-05  Szabolcs Nagy  <szabolcs.nagy@arm.com>
 
        * sysdeps/ieee754/flt-32/s_sinf.c (sinf): Use isless.
index 8b98573ae476013f7264d8b09f86e126ccb9dde5..418d4487c52423dac7c28aa43361f8b00320c8d4 100644 (file)
@@ -75,7 +75,7 @@ static const double invpio4_table[] = {
   0x1.0e4107cp-169
 };
 
-static const int ones[] = { +1, -1 };
+static const double ones[] = { 1.0, -1.0 };
 
 /* Compute the sine value using Chebyshev polynomials where
    THETA is the range reduced absolute value of the input
@@ -92,7 +92,7 @@ reduced (const double theta, const unsigned int n,
   const double theta2 = theta * theta;
   /* We are operating on |x|, so we need to add back the original
      signbit for sinf.  */
-  int sign;
+  double sign;
   /* Determine positive or negative primary interval.  */
   sign = ones[((n >> 2) & 1) ^ signbit];
   /* Are we in the primary interval of sin or cos?  */