Pow and PowI Intrinsics

All,

When one is trying to take a floating-point value to an integer power, what is the difference between casting the int to a float and using the pow intrinsic and using the powi intrinsic directly on the values?

Thanks,
Billy Moses

In principle, powi could use a series of multiplications to compute the result more efficiently than replacing the pow(x,y) with exp(y * log(x)).

(I implemented this once in a different compiler.) Whether it’s worthwhile for any particular exponent depends on the details of the target, although you could expect that powi(x, 2) would be better done as x * x than as a true exponentiation pretty much everywhere.

For a non-constant exponent one could argue for a runtime switch.

(I don’t know whether LLVM itself does any of these things, I’m just going on the principles.)

–paulr