This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop unrolling
- To: Stephen Williams <steve at icarus dot icarus dot com>
- Subject: Re: Loop unrolling
- From: Branko Cibej <branko dot cibej at hermes dot si>
- Date: Mon, 01 Jun 1998 23:22:19 +0200
- Cc: egcs at cygnus dot com
- Organization: HERMES SoftLab
- References: <199806011514.IAA02191@icarus.icarus.com>
Stephen Williams wrote:
> pfeifer@dbai.tuwien.ac.at said:
> > As a matter of fact, is there still any strong reason not to delete
> > empty loops in general?
>
> As a matter of fact, there is. Us embedded programmers are sometimes
> compelled to write timing loops. I guess we should (and I usually do)
> make those loops non-empty, but still ....
Somebody on this list mentioned making the loop variable volatile, as in:
{
int volatile i:
for (i = 0; i < 10000; ++i);
}
The compiler mustn't delete the accesses to i, therefore it can't make
the loop empty and therefore it can't delete it.
I do believe this is the way delay loops should be written.
--
Branko Cibej <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70