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 writes ...
> 
> 
> 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 ....

Is there any compelling reason why this shouldn't be an asm() block,
since otherwise optimizer changes could change the length of the loop?
For example, an "intelligent" loop optimizer could add nop's to a loop
to improve alignment, cache, or scheduling constraints.

It seems to me that such a timing loop relies on the loop generating the
same code, and as such is better as an explicit asm statement.  Linux,
for example, gets this right.

So there really is no need for an empty loop in such a case.

---------------------------------------------------------------------------
Tim Hollebeek                           | "Everything above is a true
email: tim@wfn-shop.princeton.edu       |  statement, for sufficiently
URL: http://wfn-shop.princeton.edu/~tim |  false values of true."


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