Function Descriptions
3.38 Fast Square Root
Description:
This function is an inline optmized fast square root function using two iterations of the newton
raphson method to achieve an accurate result.
Header File:
FPU.h
Declaration:
inline static float32 __ffsqrtf(float32 x)
Usage:
__ffsqrtf(x);
float32 x
input variable
Alignment Requirements:
None
Notes:
1. Performance is best with -o2, -mn compiler options (cgtools v6.0.1)
Example:
#include "FPU.h"
float32 x,y;
main()
{
y = __ffsqrtf(x);
}
Benchmark Information:
A single invocation of the __ffsqrtf function takes 22 cycles to complete. Inspection of the
generated assembly code would reveal 11 NOP’s used as delay slots between instructions. If
the user were to chain back-to-back invocations of the __ffsqrtf function, and then subsequently
use the results in either arithmetic or assignment statements, the compiler will interleave the
instructions of both functions, effectively resulting in 11 cycles per function call. The compiler
will not interleave the instructions of back-to-back functions if their results are subsequently
used in logical statements.
Sep 10, 2012 72