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


Joe Buck wrote:

> > > If you can provide source examples which show C++ & Java creating empty
> > > loops behind the programmer's back it would go a long way to convincing
> > > everyone that eliminating empty loops is a good idea.
> >
> > I sent this to RMS years ago during the original empty loop debate
> > (1991?) but he had already made up his mind.  I don't remember if I
> > sent it to the gcc2 list.
> >
> >       struct x
> >       {
> >         x() {}
> >       };
> >
> >       f()
> >       {
> >         x x1[10];
> >       }
>
> Yup.  I suppose if anyone really cares about keeping RMS happy, loops
> could be flagged as "the user wrote this loop" vs. "the compiler wrote
> this loop".

I don't think that's sufficient. My previous post with the template class
example contains only loops written by the user -- but some STL containers
(e.g., vector) have almost identical initialisation code.

Yes, the compiler could treat code in the standard library as "written by the
compiler", but what if the user wrote her own STL-like container?

(I'm sure nobody wants a new #pragma :)

> This might also keep embedded programmers who believed the gcc manual
> and wrote timing loops happy.

If they want _accurate_ timing loops, they should, as Tim Hollebeek pointed
out, use asm statements. Otherwise they can always use volatile loop variables.

--
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]