A simple optimization proposal
Martin Grajcar
maaartinus at gmail.com
Wed Feb 12 15:32:42 PST 2014
Hi John, Chris, and Vladimir,
I guess the Gist replacing
(x & array.length - 1) u< array.length
by
array.length != 0
can be easily changed to implement
(x & (m-1)) u< m, if and only if (m > 0)
in general, but I wonder if it will result in the optimal code for arrays,
which can look like
int mask = array.length - 1; // already there
if (mask < 0) goAway();
where the second line on i86 translates to simply jump if sign, i.e., a
conditional branch without any test as the flags has been already set.
This uses the equivalence m > 0 if and only if (m-1) >= 0 which holds with
the exception of m = Integer.MIN_VALUE. When checking array bounds, this
exception can't occur.
Regards,
Martin.
On Wed, Feb 12, 2014 at 11:00 PM, Vladimir Kozlov <
vladimir.kozlov at oracle.com> wrote:
> Looks reasonable. Kris, you need also look for other patterns listed in
> JDK-8003585.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20140213/999dc66d/attachment.html
More information about the hotspot-compiler-dev
mailing list