On Mon, 2011-11-14 at 17:49 -0800, Dror Maydan wrote:
> Given code such as
>
> #include <math.h>
> float dz[100];
> int foo()
> {
> int i;
> for (i=0; i<100; i++) {
> dz[i] = sqrtf(dz[i]);
> }
> }
>
>
> Open64 generates (on X86) a sqrt instruction followed by a conditional
> call to the sqrtf library function.
>
> __sqrt_arg_temp_0 = dz[i];
> __save_sqrt_temp_1 = _F4SQRT(__sqrt_arg_temp_0);
> if(__save_sqrt_temp_1 != __save_sqrt_temp_1)
> {
> __save_sqrt_temp_1 = sqrtf(__sqrt_arg_temp_0);
> }
>
>
> Does anyone know the motivation for the library call? Is something
> missing in the X86 hardware instruction, some error value in the library
> that needs to be set, something else?
This is done to set errno. If the sqrt instruction returns a NaN, then
the library function is called to make sure that errno is set correctly
for the error that occurred.
> Seems like a pretty high performance penalty for this behavior.
The assumption is that errors will not happen very often.
>
> Dror
>
> PS gcc seems to do the same thing
It can be turned off for GCC (and probably open64) with -fno-math-errno.
Steve Ellcey
[email protected]
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel