This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Loop unrolling


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]