|
|
"Anders K." <and### [at] kaseorgcom> wrote:
> A reasonably smart compiler will optimize "src_vec->x * src_vec->x" to "x
=
> src_vec->x; x * x", but I doubt it would change "pow(x, 2)" to "x * x".
>
> Even if pow is included on the CPU, multiplication is much faster (AFAIK).
Right.
As to the direct support of pow() in the CPU, this is very and very
unlikely... Usually, pow() is implemented as a function that computes its
result using the
x ^ y == 2 ^ (y * log2(x))
formula, with *some* support for the log2(x) in the CPU (power of 2, being a
shift, is quite efficient, of course). log2(x) may easily take a hundred or
so cycles, plus those extra calculations, plus the overhead of the function
call... so, hope you got the idea.
Post a reply to this message
|
|