Loop oddity

mike stump mrs@windriver.com
Tue Jan 22 13:31:00 GMT 2002


> To: gcc@gcc.gnu.org
> Date: Tue, 22 Jan 2002 12:08:43 -0500 (EST)
> From: "John David Anglin" <dave@hiauly1.hia.nrc.ca>

> Here is a loop oddity that I noticed.  The loop 

>   for (i = 1000000; i; i--) {};

> I noticed this trying to write a little program to check insn
> timing.  Thus, I didn't want the loop transformed.

You cannot rely upon gcc not optimizing it away completely.  Now is
the time to fix your code.  We suggest accessing a volatile object
inside the loop.



More information about the Gcc mailing list