http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21855
--- Comment #22 from Andrew Haley <aph at gcc dot gnu.org> 2012-01-10 17:08:30 UTC --- (In reply to comment #21) > The Java frontend could handle this by performing loads of the length field > via a SAVE_EXPR and sharing this across a function. That way CSE would > happen automagically. Now that's a nice idea. In this specific case it should be easy, because array.length is used in the control expression for the loop. So. we can create the SAVE_EXPR when the loop is initialized. The problem with doing this in general is that we don't have a CFG, so we don't always know when to create that SAVE_EXPR. If we can find an initial use of an array that dominates all other uses we can create the SAVE_EXPR at that point.