C optimizer

Leo de Wit leo at philmds.UUCP
Tue Feb 14 19:22:17 AEST 1989


In article <515 at larry.UUCP> jwp at larry.UUCP (Jeffrey W Percival) writes:
|I have a question about how much optimizing I should worry about when
|writing programs in C.  Suppose I have this code fragment:
|
|	x = (1 + cos(r)) / (cos(r) * sin(r));
|	y = (cos(r) - sin(r)) / (1 + sin(r));
|
|I made this up, but the point is the re-use of the sin() and cos()
|calls.  Now, can I expect the compiler to form only one call to sin and
|cos?

Try rand() instead of sin(), cos(). Now, you wouldn't want the compiler
to form only one call to rand(), would you?

    Leo.



More information about the Comp.lang.c mailing list