How smart is the Compiler with math.h

Hello everyone!

I have hit the speed wall and it seems that floating point operations is holding the application back from early completion, though I doubt there is any way around. My question is:

How smart is the compiler when it comes to some common functions in math.h, namely pow. When the "exponent" is a small integer, for example pow(x,3), does the function return x*x*x?

Are there some smart shortcuts supported too by math.h to anyone\s knowledge?

Thanks!
Compilers are generally not clever enough to to outright eliminate function calls. Clang is probably the cleverest, and I doubt it can do it.

I'm not sure if this is standard behavior, but VC++ defines a pow(double,int) overload that uses a loop instead of calling the actual pow(). When both parameters are double, though, like in pow(3.141592,2.0), it still does call pow().
VC++ defines a pow(double,int) overload that uses a loop instead of calling the actual pow()


I doubt it works if you use math.h, I think only works with cmath.
Topic archived. No new replies allowed.