RFR: 8276162: Optimise unsigned comparison pattern [v3]

Mai Đặng Quân Anh duke at openjdk.java.net
Sat Nov 13 05:25:33 UTC 2021


On Thu, 11 Nov 2021 08:33:25 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> Mai Đặng Quân Anh has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - replace cmpx->Opcode() with cmpx_op
>>  - address reviews, remove checks for subtraction operatios
>
> Given that there is `Integer/Long.compareUnsigned` using this idiom, it seems reasonable to optimize. Some general comments:
> - Your benchmark does not cover all the cases you are optimizing. Maybe you should also add the `Integer.compareUnsigned` variants.
> - You need a correctness test as well, ideally using the IR verification framework to also verify that the optimizations are actually performed.

@TobiHartmann  Thank you very much for the review, I have added the correctness test as well as revised the microbenchmark to cover all the situations including calling to `[Integer/Long].compareUnsigned`. The result of the benchmark is as follow:

    Before:
    Benchmark                         Mode  Cnt     Score    Error  Units
    UnsignedComparison.intConDirect   avgt   10   927.540 ± 19.142  ns/op
    UnsignedComparison.intConLibGT    avgt   10   916.753 ±  4.502  ns/op
    UnsignedComparison.intConLibLT    avgt   10   927.911 ± 15.027  ns/op
    UnsignedComparison.intVarDirect   avgt   10  1005.895 ± 14.030  ns/op
    UnsignedComparison.intVarLibGT    avgt   10   999.216 ±  1.528  ns/op
    UnsignedComparison.intVarLibLT    avgt   10  1000.501 ±  4.117  ns/op
    UnsignedComparison.longConDirect  avgt   10  1082.950 ±  8.166  ns/op
    UnsignedComparison.longConLibGT   avgt   10  1081.340 ±  6.883  ns/op
    UnsignedComparison.longConLibLT   avgt   10  1079.599 ±  4.229  ns/op
    UnsignedComparison.longVarDirect  avgt   10  1131.605 ± 76.268  ns/op
    UnsignedComparison.longVarLibGT   avgt   10  1180.006 ±  7.018  ns/op
    UnsignedComparison.longVarLibLT   avgt   10  1178.463 ±  0.809  ns/op

    After:
    Benchmark                         Mode  Cnt    Score    Error  Units
    UnsignedComparison.intConDirect   avgt   10  740.951 ±  5.020  ns/op
    UnsignedComparison.intConLibGT    avgt   10  808.425 ±  2.989  ns/op
    UnsignedComparison.intConLibLT    avgt   10  740.029 ±  1.332  ns/op
    UnsignedComparison.intVarDirect   avgt   10  911.489 ±  4.700  ns/op
    UnsignedComparison.intVarLibGT    avgt   10  979.338 ±  8.130  ns/op
    UnsignedComparison.intVarLibLT    avgt   10  910.429 ±  3.452  ns/op
    UnsignedComparison.longConDirect  avgt   10  750.174 ±  5.915  ns/op
    UnsignedComparison.longConLibGT   avgt   10  828.144 ± 53.091  ns/op
    UnsignedComparison.longConLibLT   avgt   10  771.493 ± 52.902  ns/op
    UnsignedComparison.longVarDirect  avgt   10  882.139 ±  2.091  ns/op
    UnsignedComparison.longVarLibGT   avgt   10  952.862 ± 10.248  ns/op
    UnsignedComparison.longVarLibLT   avgt   10  881.623 ±  1.895  ns/op

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

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


More information about the hotspot-compiler-dev mailing list