JIT code generation for Long/Integer.compare

Ian Rogers irogers at google.com
Thu Sep 24 18:45:53 UTC 2015

Below is a patch to add JIT code generation for Long/Integer.compare. It
has been reviewed internally by rasbold at google.com. I'd like to open a bug
for this, get it reviewed, etc. but I lack a JBS account. I'd appreciate
help in getting this reviewed and merged.

Ian Rogers

Support JIT code generation for Long/Integer.compare as intrinsics that
fold with branches on their result.

Introduce a CmpI3 ideal node mirroring the CmpL3 node, that implements
Integer.compare. Allow this to fold with a CmpI node.  Spot
as CmpL3 and CmpI3 nodes.  Add a CmpI3 implementation for x86-64.  On a
micro-benchmark loop of:
    for (int i = 0; i < x.length; i++) {
      if (compare(x[i], y[i]) < 0) {
Int speed up averages 1.18x, long speed up averages 2.76x, over 30 runs of
arrays sized at 5,000,000 elements. This can be improved with work on
instruction selection.
Raw data:
Int before:  23129us, 99.5% range: 19935us - 26046us
Int after:   19557us, 99.5% range: 16972us - 26072us
Long before: 26935us, 99.5% range: 25776us - 29323us
Long after:   9749us, 99.5% range: 8850us  - 11968us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150924/a1c24f46/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmpi3-jdk9-tdiff.patch
Type: text/x-patch
Size: 10807 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150924/a1c24f46/cmpi3-jdk9-tdiff-0001.patch>

More information about the hotspot-compiler-dev mailing list