[cfe-dev] Floating-point performance question

Richard Hadsell hadsell at blueskystudios.com
Fri Sep 6 08:19:33 PDT 2013


On 09/05/2013 04:44 PM, Richard Hadsell wrote:
> Thanks for all the clues.  Here is the stack trace:
>   feholdexcept,
>   __ieee754_exp2,
>   exp2,
>   _ZN9cgi...
> Based on your various hints, I'm guessing that our code 'pow (2.0, x)' is being optimized by Clang++ to 'exp2 (x)' and not by G++. We will try using exp2 explicitly and see what happens with the G++ version.
>
> Perhaps we are running into a floating-point standards issue that our old version of G++ is ignoring.
>
> We'll continue investigating tomorrow.

We changed our code to use 'exp2 (x)' instead of 'pow (2.0, x)' and verified that the G++ version now calls feholdexcept.  We'll also run our benchmarks again to compare Clang++ with G++ on our modified code.

So, the question for Clang developers is: how can we avoid the optimization that converts 'pow (2.0, x)' to 'exp2 (x)'?

I don't know why the library functions differ in their need to call feholdexcept, but regardless of the explanation, I want to pick the faster one for this particular usage.

-- 
Dick Hadsell			203-992-6320  Fax: 203-992-6001
Reply-to:			hadsell at blueskystudios.com
Blue Sky Studios                http://www.blueskystudios.com
1 American Lane, Greenwich, CT 06831-2560

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130906/5094a072/attachment.html>


More information about the cfe-dev mailing list