http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45791
--- Comment #14 from Martin Jambor <jamborm at gcc dot gnu.org> 2010-12-15 16:07:31 UTC --- (In reply to comment #9) > OK, main() code seems to optimize out that is an imrovement. Is it optimized > away with your patch pre-IPA too? Yes. Just before IPA, in fact. > > Derived() is also devirtualizable: > It could be done intraprocedurally if, unlike for automatically allocated decls, we considered all calls as potentially changing the dynamic type in unknown ways while doing the dynamic type change detection. This then however becomes essentially the same thing as devirtualization based on the constant folding, perhaps only more complicated. It could be optimized by IPA-CP if we can confirm that all callers are automatically allocated (or that we generally have them under control). This should be relatively easy, I will have a look at that. Mainly because we may be able to widen scope of objects under our control later.