RFR: 8283726: x86 intrinsics for compare method in Integer and Long
Jatin Bhateja
jbhateja at openjdk.java.net
Tue Mar 29 02:44:43 UTC 2022
On Sun, 27 Mar 2022 06:15:34 GMT, Vamsi Parasa <duke at openjdk.java.net> wrote:
> Implements x86 intrinsics for compare() method in java.lang.Integer and java.lang.Long.
src/hotspot/cpu/x86/x86_64.ad line 12107:
> 12105: instruct compareSignedI_rReg(rRegI dst, rRegI op1, rRegI op2, rRegI tmp, rFlagsReg cr)
> 12106: %{
> 12107: match(Set dst (CompareSignedI op1 op2));
Please also include these patterns in x86_32.ad
src/hotspot/cpu/x86/x86_64.ad line 12125:
> 12123: __ movl(tmp, 0);
> 12124: __ bind(done);
> 12125: __ movl(dest, tmp);
Please move this in macro-assembly routine.
src/hotspot/cpu/x86/x86_64.ad line 12178:
> 12176: __ movl(tmp, 0);
> 12177: __ bind(done);
> 12178: __ movl(dest, tmp);
Please move this into a macro-assembly routine.
src/hotspot/cpu/x86/x86_64.ad line 12204:
> 12202: __ movl(tmp, 0);
> 12203: __ bind(done);
> 12204: __ movl(dest, tmp);
Please move this into macro-assembly routine.
src/hotspot/share/classfile/vmIntrinsics.hpp line 239:
> 237: do_intrinsic(_compareUnsigned_i, java_lang_Integer, compare_unsigned_name, int2_int_signature, F_S) \
> 238: do_name( compare_unsigned_name, "compareUnsigned") \
> 239: do_intrinsic(_compareUnsigned_l, java_lang_Long, compare_unsigned_name, long2_int_signature, F_S) \
Creating these methods as intrinsic will create a box around the underneath comparison logic, this shall prevent any regular constant folding which could have optimized out certain control paths, I would suggest to to handle constant folding for newly added nodes in associated Value routines.
src/hotspot/share/opto/comparenode.hpp line 67:
> 65: CompareUnsignedLNode(Node* in1, Node* in2) : CompareNode(in1, in2) {}
> 66: virtual int Opcode() const;
> 67: };
Intent here seems to be to enable further auto-vectorization of newly create IR nodes.
test/micro/org/openjdk/bench/java/lang/CompareInteger.java line 78:
> 76: input2[i] = tmp;
> 77: }
> 78: }
Logic re-organization suggestion:-
for (int i = 0 ; i < BUFFER_SIZE; i++) {
input1[i] = rng.nextLong();
}
if (mode.equals("equals") {
GRADIANT = 0;
} else if (mode.equals("greaterThanEquals")) {
GRADIANT = 1;
} else {
assert mode.equals("lessThanEqual");
GRADIANT = -1;
}
for(int i = 0 ; i < BUFFER_SIZE; i++) {
input2[i] = input1[i] + i*GRADIANT;
}
test/micro/org/openjdk/bench/java/lang/CompareLong.java line 5:
> 3: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> 4: *
> 5: * This code is free software; you can redistribute it and/or modify it
We can unify this benchmark along with integer compare micro.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7975
More information about the core-libs-dev
mailing list