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.


Device: TMS320C8x
Category: TI Tools
Detail: Code Generation Tools
Detail2: Compiler
Title: C Compiler Doesn't use Square Root Instruction
Source: Case from TMS320 Hotline
Date: 8/1/97
GenId: 0008024

© Copyright 1998 Texas Instruments Incorporated. All rights reserved.
Trademarks, Important Notice!