diff mbox series

math: Use sign as double for reduced case in sinf

Message ID 1512495456-10490-1-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series math: Use sign as double for reduced case in sinf | expand

Commit Message

Adhemerval Zanella Dec. 5, 2017, 5:37 p.m. UTC
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                       | 5 +++++
 sysdeps/ieee754/flt-32/s_sinf.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

-- 
2.7.4

Comments

Joseph Myers Dec. 5, 2017, 5:57 p.m. UTC | #1
On Tue, 5 Dec 2017, Adhemerval Zanella wrote:

> 	* sysdeps/ieee754/flt-32/s_sinf.c (ones): Define as double.

> 	(reduced): Use ones as double instead of integer.


OK.

-- 
Joseph S. Myers
joseph@codesourcery.com
diff mbox series

Patch

diff --git a/sysdeps/ieee754/flt-32/s_sinf.c b/sysdeps/ieee754/flt-32/s_sinf.c
index 0b76477..05edd48 100644
--- a/sysdeps/ieee754/flt-32/s_sinf.c
+++ b/sysdeps/ieee754/flt-32/s_sinf.c
@@ -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?  */