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]
Other format: [Raw text]

Re: How to detect whether we're inside of a loop??


 > From: Geoff Keating <geoffk at geoffk dot org>
 > 
 > > Date: Wed, 9 Apr 2003 16:56:55 -0400 (EDT)
 > > From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
 > 
 > > I think your approach would be suited for finding which of the if-else
 > > branches to choose.  Finding the looping spots is what I'm looking
 > > for because I think it has more impact.
 > > 
 > > Do you agree with this line of reasoning?
 > 
 > No, not really.  For instance, a little-known fact is that the
 > average number of iterations for a loop is about 1.5; someone did
 > some analysis on some huge collection of programs and this is the
 > number they came up with.

Interesting, do you have a URL article with the research?  I'd like to
read it.

By the way, 1.5 > 1. :-)

The average you cite above for loops means that the loop-body is still
executed more often than code which is not in a loop, just not by as
much as I'd hoped.  And if-then clauses have execution probability of
less than one for each clause so code in there is even less likely to
be executed than loop bodies.

You've proved my point, simply with a smaller margin.

		Thanks, ;-)
		--Kaveh
--
Kaveh R. Ghazi			ghazi at caip dot rutgers dot edu


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