This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/21855] array bounds checking elimination
- From: "aph at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Jan 2012 17:08:30 +0000
- Subject: [Bug java/21855] array bounds checking elimination
- Auto-submitted: auto-generated
- References: <bug-21855-4@http.gcc.gnu.org/bugzilla/>
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.