This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop unrolling
- To: egcs at cygnus dot com
- Subject: Re: Loop unrolling
- From: Nathan Myers <ncm at cygnus dot com>
- Date: Wed, 03 Jun 1998 09:50:17 -0700
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
- References: <199806022148.OAA03667@atrus.synopsys.com>, <35750FDB.E00386FE.cygnus.egcs@hermes.si>
Branko Cibej wrote:
> 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.
This is absolutely correct. The performance of programs that use STL
facilities, and similar libraries like Blitz++, is utterly dependent on
the compiler crushing out "abstraction overhead", which often means
empty loops.
It is impossible in general for the programmer to ensure that empty loops
are not generated, because with templates there is no one place in the source
where all such knowledge is available.
Perhaps in C code such loops cannot be eliminated without some political
wrangling, but there can be no such excuse for g++.
Nathan Myers
ncm@cygnus.com