------- Additional Comments From rguenth at gcc dot gnu dot org 2005-05-11 09:35 ------- Mainline now has
void foo(const Flag&) (f) { const bool D.1718; int D.1717; struct Flag * const this; const bool D.1713; int D.1712; struct Flag * const this; bool D.1707; bool retval.1; bool D.1705; bool retval.0; int D.1716; int D.1711; <bb 0>: if (f->flag != 0) goto <L1>; else goto <L5>; <L1>:; bar (); if (f->flag != 0) goto <L4>; else goto <L5>; <L4>:; bar () [tail call]; <L5>:; return; } I.e. the missing jump threading is done, but still f->flag is seen as possibly clobbered by the call to bar(). Still a language lawyer has to sneak in and tell this optimization would be indeed valid. The key is privateness or constness of Flag::flag. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19507