On Mon, Aug 08, 2005 at 04:29:57PM +0300, Omer Zak wrote:
> 1. How do you ensure that the compiler did not optimize away the
> assignment to q or the call to sqrt() due to recognition that it has no
> side-effects (in 80x86 processors, there is a FP sqrt instruction so a
> serious compiler knows to inline the function call and that it leaves no
> side effects)?

By invoking gcc -S and examining the assembly file. Without 
optimization, gcc calls sqrt in a loop. With -O3, gcc inlines 
floating-point instructions to compute sqrt, defaulting to sqrt()
in case they somehow go wrong (but apparently here they never do).
It still does everything in a loop and stored the result each time
in a local variable. 

I don't know what icc does, I don't have it installed.

-- 
avva
"There's nothing simply good, nor ill alone" -- John Donne


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to