This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/5] Use fabs(x) instead of branching on signedness of input to sin and cos


On Tue, 23 Aug 2016, Siddhesh Poyarekar wrote:

> 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.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]