How to detect whether we're inside of a loop??
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Fri Apr 11 05:59:00 GMT 2003
> From: Geoff Keating <geoffk@geoffk.org>
>
> > Date: Wed, 9 Apr 2003 16:56:55 -0400 (EDT)
> > From: "Kaveh R. Ghazi" <ghazi@caip.rutgers.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@caip.rutgers.edu
More information about the Gcc
mailing list