RFR: 8283726: x86 intrinsics for compare method in Integer and Long

Vamsi Parasa duke at openjdk.java.net
Tue Mar 29 22:07:49 UTC 2022


On Sun, 27 Mar 2022 06:57:58 GMT, Quan Anh Mai <duke at openjdk.java.net> wrote:

> This is both complicated and inefficient, I would suggest building the intrinsic in the IR graph so that the compiler can simplify `Integer.compareUnsigned(x, y) < 0` into `x u< y`. Thanks.

Thank you for the suggestion! This intrinsic uses 1 cmp instruction instead of two and shows ~10% improvement due to better branch prediction. Even without the intrinsic, the compiler is currently able to reduce it to x u< y but is still generating two cmp (unsigned) instructions as Integer.compareUnsigned(x, y) is implemented as x u< y? -1 : (x ==y ? 0 : 1).

-------------

PR: https://git.openjdk.java.net/jdk/pull/7975


More information about the core-libs-dev mailing list