Math trig intrinsics and compiler options

Tom Rodriguez Thomas.Rodriguez at Sun.COM
Wed Jul 15 10:03:05 PDT 2009


> Thats how i interpret the difference too, and correct me if im  
> wrong  but the rounding is only needed for the strictmath to get its  
> platform independent exact results and not for Math ?.

StrictMath requires exact answers for all of these routines and the  
intel instructions don't have adequate accuracy to be used for them.   
The regular Math routines have some freedom to differ from the strict  
implementation but they can't be arbitrarily bad and the rounding  
logic that wraps the instructions ensures that we get back valid  
values outside the range where those instructions return reasonable  
answers.  Check out http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4345903 
.

As far as why sharedRuntimeTrig.cpp disables compiler optimizations,  
these functions are from fdlibm and require very precise fp semantics  
which are generally violated by the optimizers in most compilers.  If  
you turn on optimizations then these routines won't return the right  
answer anymore.

tom

>
> when testing with the input ranges that matches the different code  
> paths (PI/4 , 3PI/4, 2^19*(pi/2)) with 1 minute runtime per test i  
> get consistent improvement of roughly (40%, 100%, 32% ) for  
> Math.sin  and similar for cos.
>
>
> -- 
> regards
>  gustav trede
>
>




More information about the hotspot-dev mailing list