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


> I was interested in experimenting with heuristics which might expand a
> builtin depending on whether at the point of expansion we're in a loop
> or not.  E.g. It might make sense to expand something which might
> create slightly larger code only if we think it's likely that it'll be
> executed a number of times.  I'm guessing that being inside a loop is
> one way to increase that probability.  Thus I was curious if there's a
> way to detect this.  So my questions are:
> 
> 1.  Can we detect this?  (C'mon there's gotta be a way.)
> 
> 2.  Is it cheap to detect or a heavy calculation?  Ie. I don't want to
>     have to do an expensive optimization pass just to figure this out.
>     I'm hoping that I can just access a bit somewhere that tells me
>     yes or no.
> 
> 3.  Is it practical to detect this at the point I'm interested in,
>     ie. inside an expand_builtin_foo function?
> 
> 4.  Is there another way to conceptually do what I want, ie. detect
>     that the code in question is likely to be executed more than once?
> 
> 5.  Can you explain it all simply enough for me to understand? :-)
> 
> 		Thanks,
> 		--Kaveh

What would it mean if the loop had been unwound or an iteration peeled off?

What would it mean if the loop were inside an inline function which was 
itself called from a loop?

R.


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