for(;;) vs. while(1) is a draw
Blair P. Houghton
bph at buengc.BU.EDU
Sat May 26 04:02:44 AEST 1990
In article <16725 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
>In article <5897 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
>>If I were to write a compiler under K&R1 and provide a no-optimization mode,
>>`for(;;)' would be an unconditional branch and `while(1)' would compare 1 to
>>0 and then branch-if-unequal, because that's what the syntax implies.
>
>I suppose you would also compile `if (x==y)' into code that compares x against
>y, sets a temporary to either 0 or 1, and then compares that value against
>zero, right?
Yes. Then I'd compile it with a `-O' flag and the computer
wouldn't even have to load x and y. It would _know_ they're
unequal just by smelling them.
>Your statements are vacuously true, because according to your definitions,
>nobody has ever written a "non-optimizing" compiler.
Probably. Everyone wants to be helpful.
--Blair
"Gilligan, If you wanna help, don't help."
-The Skipper
More information about the Comp.std.c
mailing list