A simple optimization proposal

John Rose john.r.rose at oracle.com
Fri Feb 14 15:45:26 PST 2014

On Feb 14, 2014, at 10:54 AM, Krystal Mok <rednaxelafx at gmail.com> wrote:

> There's no dominating check on elements.length, so a range check will still have to be generated in this case. Simplifying the check to (elements.length != 0) or (elements.length u> 0) doesn't really buy much, because the final index is calculated and put into a register already anyway, doing the normal (index u< elements.length) check before this patch should be just as fast.

I think there is a small benefit to simplifying the range check to a test against zero:  It reduces the use count of "head" (possible register pressure effect) and the number of inputs to the test (possible scheduling effect, including runtime hardware micro-ops).

But the case of HashMap is better, since we can piggy-back the reduced range check on top of the pre-existing empty-table check.

— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20140214/12d2d372/attachment.html 

More information about the hotspot-compiler-dev mailing list