How to detect whether we're inside of a loop??
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Tue Apr 8 21:55:00 GMT 2003
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@caip.rutgers.edu
More information about the Gcc
mailing list