[llvm-commits] Patch: Math Lib call optimization

Weiming Zhao weimingz at codeaurora.org
Wed Nov 2 12:42:26 PDT 2011


Hi Duncan,

Thanks for your comments.

The precision loss will happen when the results of sin((double)x) and
sinf(x) differ within a single precision ulps. It might happen only in very
rare cases. So, theoretically, you're right. :D 
But in practice, I did experiments by comparing the results of (float)sin(x)
and sinf(x) for random inputs. The results are the same. And for users who
are really concern about precision, they can disable this pass.

Weiming Zhao


-----Original Message-----
From: llvm-commits-bounces at cs.uiuc.edu
[mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Duncan Sands
Sent: Wednesday, November 02, 2011 11:25 AM
To: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] Patch: Math Lib call optimization

Dear Weiming Zhao,

> Hence, this transformation will not result in precision loss.

is this a correct statement?  For example, if sin returns a result which is
correct to within two double precision ulps, and sinf to within two single
precision ulps, then float->double->sin->float will probably be correct to
one single precision ulp, so converting to use sinf loses precision.

Ciao, Duncan.
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list