Use fabs(x) instead of branching on signedness of input to sin and cos
commit9d84d0e51d0a590024a050b64e04df3214a04a01
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Tue, 30 Aug 2016 07:31:59 +0000 (30 13:01 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Tue, 30 Aug 2016 07:31:59 +0000 (30 13:01 +0530)
tree405fa710f8935267462877342a76feb9bc8f67d8
parent1a822c61844eb378bc8d676f26edf1a0285303b1
Use fabs(x) instead of branching on signedness of input to sin and cos

The sin and cos code is inconsistent about its use of fabs to get the
absolute value of X where in some places it conditionalizes the code
while in others it uses fabs.  fabs seems to be a better candidate in
most cases because it avoids a branch.  Similarly there is an attempt
to make it easier for the compiler to emit conditional assignment
instructions (like fcsel on aarch64) where it can, by isolating
conditional assignment constructs from the rest of the expression.

A further benefit of this change is to identify common constructs
across functions and consolidate them in future patches.

* sysdeps/ieee754/dbl-64/s_sin.c (do_cos_slow): Use ternary
instead of if/else.
(do_sin_slow): Likewise.
(do_sincos_1): Use fabs instead of if/else.
(do_sincos_2): Likewise.
(__sin): Likewise.
(__cos): Likewise.
(slow2): Likewise.
(sloww): Likewise.
(sloww1): Likewise.  Drop argument M.
(sloww2): Use fabs instead of if/else.
(bsloww): Likewise.
(bsloww1): Likewise.
(bsloww2): Likewise.
ChangeLog
sysdeps/ieee754/dbl-64/s_sin.c