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

Siddhesh Poyarekar siddhesh@gotplt.org
Wed Aug 24 02:50:00 GMT 2016


On Wednesday 24 August 2016 02:23 AM, Manfred wrote:
> If eps is known to be >=0 then
>> +  cor = 1.0005 * cor + ((cor > 0) ? eps : -eps);
> might be written as
> cor = 1.0005 * cor + copysign(eps, cor);
>
> Similarly to fabs(), copysign() avoids a branch - or a potential one
> from the ternary.

Thanks, there are a lot of places in the code that can benefit from 
this, so I'll post a separate patch to clean it all up.

Siddhesh



More information about the Libc-alpha mailing list