[Mesa-dev] [PATCH] gallivm: unify sin and cos implementation

Roland Mainz roland.mainz at nrubsig.org
Tue Aug 20 16:28:40 PDT 2013


On Wed, Aug 21, 2013 at 1:12 AM,  <sroland at vmware.com> wrote:
> From: Roland Scheidegger <sroland at vmware.com>
>
> The (complicated!) math is all identical, there's just minimal differences how
> sign bit is calculated plus there's an additional subtraction for the argument
> going into the polynomial for cos.
> The logic stays 100% the same (with a small exception, sign bit calculation for
> sin is minimally simplified, applying sign mask after xoring the arguments
> instead of applying it to each argument).
> ---
>  src/gallium/auxiliary/gallivm/lp_bld_arit.c |  300 ++++-----------------------
>  1 file changed, 46 insertions(+), 254 deletions(-)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> index f7daabc..03e0aa6 100644
[snip]
> -   /* If a is -inf, inf or NaN then return NaN */
[snip]

Note that the comment about NaN in the old code is not 100% correct
(ksh93 and ISO C behave the same in this case since POSIX sh $((...))
uses ISO C expressions):
-- snip --
$ ksh93 -c 'print -- $(( sin(-nan) ))'
-nan
$ ksh93 -c 'print -- $(( sin(+nan) ))'
nan
-- snip --

Can you check whether the new code supports -nan correctly, please
(-nan is used by scientific software... we learned that the hard way
when we had to fix this in ksh93 for Sun) ?

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)


More information about the mesa-dev mailing list