RFR: 8287925: AArch64: intrinsics for compareUnsigned method in Integer and Long

Andrew Haley aph at openjdk.org
Thu Dec 1 11:46:21 UTC 2022


On Mon, 28 Nov 2022 02:31:25 GMT, Hao Sun <haosun at openjdk.org> wrote:

> x86 implemented the intrinsics for compareUnsigned() method in Integer and Long. See JDK-8283726. We add the corresponding AArch64 backend support in this patch.
> 
> Note-1: minor style issues are fixed for CmpL3 related rules.
> 
> Note-2: Jtreg case TestCompareUnsigned.java is updated to cover the matching rules for "comparing reg with imm" case.
> 
> Testing: tier1~3 passed on Linux/AArch64 platform with no new failures.
> 
> Following is the performance data for the JMH case:
> 
> 
>                                                        Before          After
> Benchmark                         (size) Mode  Cnt   Score   Error  Score   Error  Units
> Integers.compareUnsignedDirect      500  avgt    5   0.994 ± 0.001  0.872 ± 0.015  us/op
> Integers.compareUnsignedIndirect    500  avgt    5   0.991 ± 0.001  0.833 ± 0.055  us/op
> Longs.compareUnsignedDirect         500  avgt    5   1.052 ± 0.001  0.974 ± 0.057  us/op
> Longs.compareUnsignedIndirect       500  avgt    5   1.053 ± 0.001  0.916 ± 0.038  us/op

Try this one:


    @Benchmark
    public int compareUnsignedDirect(Blackhole bh) {
        int probe1 = seed, probe2 = seed ^ seed << 5;
        int sum = 0;
        for (int i = 0; i < size; i++) {
            probe1 ^= probe1 << 13;
            sum += Integer.compareUnsigned(probe1, Integer.MAX_VALUE) /* <= 0 ? 1 : 0 */;        probe2 ^= probe2 << 13;
            probe1 ^= probe1 >>> 17;                            sum += Integer.compareUnsigned(probe2, Integer.MAX_VALUE) /* <= 0 ? 1 : 0 */;
            sum += Integer.compareUnsigned(probe1, Integer.MAX_VALUE) /* <= 0 ? 1 : 0 */;        probe2 ^= probe2 >>> 17;
            probe1 ^= probe1 << 5;                              sum += Integer.compareUnsigned(probe2, Integer.MAX_VALUE) /* <= 0 ? 1 : 0 */;
            sum += Integer.compareUnsigned(probe1, Integer.MAX_VALUE) /* <= 0 ? 1 : 0 */;        probe2 ^= probe2 << 5;
                                                                sum += Integer.compareUnsigned(probe2, Integer.MAX_VALUE) /* <= 0 ? 1 : 0 */;
        }
        seed = probe2 + probe1;
        return sum;
    }



Does that help?

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

PR: https://git.openjdk.org/jdk/pull/11383


More information about the hotspot-compiler-dev mailing list