This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
How to detect whether we're inside of a loop??
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 8 Apr 2003 16:13:24 -0400 (EDT)
- Subject: 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
--
Kaveh R. Ghazi ghazi at caip dot rutgers dot edu