This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop oddity
- From: mike stump <mrs at windriver dot com>
- To: dave at hiauly1 dot hia dot nrc dot ca, gcc at gcc dot gnu dot org
- Date: Tue, 22 Jan 2002 11:18:03 -0800 (PST)
- Subject: Re: Loop oddity
> 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.