 Question:
The MP has a native square root instruction, but the C compiler doesn't use it. Not only
does the compiler not inline a square root, but the run-time library implementation does
what seems to be a rather lengthy approximation (25 floating multiplies, 6 floating
subtracts, and some fixed point stuff, plus the function call overhead). Is there any way
to get the compiler to inline sqrt and use the native instruction? This would be
particularly attractive for single precision (i.e. float) operands, where the fsqrt
instruction is about 3 times faster than for double operands. :
Answer: The ANSI spec states
that the sqrt function must set the errno variable based on results of the operation, so
the sqrt instruction will invalidate this rule. However, we did add the capability to call
_sqrt which will use the native sqrt inst. |