Skip to content

Commit 108cd69

Browse files
merykittyJatin Bhateja
authored and
Jatin Bhateja
committedJun 29, 2022
8283726: x86_64 intrinsics for compareUnsigned method in Integer and Long
Reviewed-by: kvn, jbhateja
1 parent b96ba19 commit 108cd69

File tree

15 files changed

+271
-11
lines changed

15 files changed

+271
-11
lines changed
 

‎src/hotspot/cpu/x86/x86_64.ad

+52
Original file line numberDiff line numberDiff line change
@@ -13022,6 +13022,32 @@ instruct testL_reg_mem2(rFlagsReg cr, rRegP src, memory mem, immL0 zero)
1302213022
ins_pipe(ialu_cr_reg_mem);
1302313023
%}
1302413024

13025+
// Manifest a CmpU result in an integer register. Very painful.
13026+
// This is the test to avoid.
13027+
instruct cmpU3_reg_reg(rRegI dst, rRegI src1, rRegI src2, rFlagsReg flags)
13028+
%{
13029+
match(Set dst (CmpU3 src1 src2));
13030+
effect(KILL flags);
13031+
13032+
ins_cost(275); // XXX
13033+
format %{ "cmpl $src1, $src2\t# CmpL3\n\t"
13034+
"movl $dst, -1\n\t"
13035+
"jb,u done\n\t"
13036+
"setne $dst\n\t"
13037+
"movzbl $dst, $dst\n\t"
13038+
"done:" %}
13039+
ins_encode %{
13040+
Label done;
13041+
__ cmpl($src1$$Register, $src2$$Register);
13042+
__ movl($dst$$Register, -1);
13043+
__ jccb(Assembler::below, done);
13044+
__ setne($dst$$Register);
13045+
__ movzbl($dst$$Register, $dst$$Register);
13046+
__ bind(done);
13047+
%}
13048+
ins_pipe(pipe_slow);
13049+
%}
13050+
1302513051
// Manifest a CmpL result in an integer register. Very painful.
1302613052
// This is the test to avoid.
1302713053
instruct cmpL3_reg_reg(rRegI dst, rRegL src1, rRegL src2, rFlagsReg flags)
@@ -13048,6 +13074,32 @@ instruct cmpL3_reg_reg(rRegI dst, rRegL src1, rRegL src2, rFlagsReg flags)
1304813074
ins_pipe(pipe_slow);
1304913075
%}
1305013076

13077+
// Manifest a CmpUL result in an integer register. Very painful.
13078+
// This is the test to avoid.
13079+
instruct cmpUL3_reg_reg(rRegI dst, rRegL src1, rRegL src2, rFlagsReg flags)
13080+
%{
13081+
match(Set dst (CmpUL3 src1 src2));
13082+
effect(KILL flags);
13083+
13084+
ins_cost(275); // XXX
13085+
format %{ "cmpq $src1, $src2\t# CmpL3\n\t"
13086+
"movl $dst, -1\n\t"
13087+
"jb,u done\n\t"
13088+
"setne $dst\n\t"
13089+
"movzbl $dst, $dst\n\t"
13090+
"done:" %}
13091+
ins_encode %{
13092+
Label done;
13093+
__ cmpq($src1$$Register, $src2$$Register);
13094+
__ movl($dst$$Register, -1);
13095+
__ jccb(Assembler::below, done);
13096+
__ setne($dst$$Register);
13097+
__ movzbl($dst$$Register, $dst$$Register);
13098+
__ bind(done);
13099+
%}
13100+
ins_pipe(pipe_slow);
13101+
%}
13102+
1305113103
// Unsigned long compare Instructions; really, same as signed long except they
1305213104
// produce an rFlagsRegU instead of rFlagsReg.
1305313105
instruct compUL_rReg(rFlagsRegU cr, rRegL op1, rRegL op2)

‎src/hotspot/share/classfile/vmIntrinsics.hpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class methodHandle;
126126
do_signature(float2_float_signature, "(FF)F") \
127127
do_signature(float3_float_signature, "(FFF)F") \
128128
do_signature(int2_int_signature, "(II)I") \
129+
do_signature(long2_int_signature, "(JJ)I") \
129130
do_signature(long2_long_signature, "(JJ)J") \
130131
\
131132
/* here are the math names, all together: */ \
@@ -150,9 +151,9 @@ class methodHandle;
150151
do_name(expand_name,"expand") \
151152
\
152153
do_intrinsic(_dabs, java_lang_Math, abs_name, double_double_signature, F_S) \
153-
do_intrinsic(_fabs, java_lang_Math, abs_name, float_float_signature, F_S) \
154-
do_intrinsic(_iabs, java_lang_Math, abs_name, int_int_signature, F_S) \
155-
do_intrinsic(_labs, java_lang_Math, abs_name, long_long_signature, F_S) \
154+
do_intrinsic(_fabs, java_lang_Math, abs_name, float_float_signature, F_S) \
155+
do_intrinsic(_iabs, java_lang_Math, abs_name, int_int_signature, F_S) \
156+
do_intrinsic(_labs, java_lang_Math, abs_name, long_long_signature, F_S) \
156157
do_intrinsic(_dsin, java_lang_Math, sin_name, double_double_signature, F_S) \
157158
do_intrinsic(_floor, java_lang_Math, floor_name, double_double_signature, F_S) \
158159
do_intrinsic(_ceil, java_lang_Math, ceil_name, double_double_signature, F_S) \
@@ -205,7 +206,7 @@ class methodHandle;
205206
do_intrinsic(_dsqrt_strict, java_lang_StrictMath, sqrt_name, double_double_signature, F_SN) \
206207
\
207208
do_intrinsic(_floatIsInfinite, java_lang_Float, isInfinite_name, float_bool_signature, F_S) \
208-
do_name( isInfinite_name, "isInfinite") \
209+
do_name( isInfinite_name, "isInfinite") \
209210
do_intrinsic(_doubleIsInfinite, java_lang_Double, isInfinite_name, double_bool_signature, F_S) \
210211
\
211212
do_intrinsic(_floatToRawIntBits, java_lang_Float, floatToRawIntBits_name, float_int_signature, F_SN) \
@@ -221,12 +222,17 @@ class methodHandle;
221222
do_intrinsic(_longBitsToDouble, java_lang_Double, longBitsToDouble_name, long_double_signature, F_SN)\
222223
do_name( longBitsToDouble_name, "longBitsToDouble") \
223224
\
224-
do_intrinsic(_divideUnsigned_i, java_lang_Integer, divideUnsigned_name, int2_int_signature, F_S) \
225-
do_intrinsic(_remainderUnsigned_i, java_lang_Integer, remainderUnsigned_name, int2_int_signature, F_S) \
226-
do_name( divideUnsigned_name, "divideUnsigned") \
227-
do_intrinsic(_divideUnsigned_l, java_lang_Long, divideUnsigned_name, long2_long_signature, F_S) \
228-
do_intrinsic(_remainderUnsigned_l, java_lang_Long, remainderUnsigned_name, long2_long_signature, F_S) \
229-
do_name( remainderUnsigned_name, "remainderUnsigned") \
225+
do_intrinsic(_compareUnsigned_i, java_lang_Integer, compareUnsigned_name, int2_int_signature, F_S) \
226+
do_intrinsic(_compareUnsigned_l, java_lang_Long, compareUnsigned_name, long2_int_signature, F_S) \
227+
do_name( compareUnsigned_name, "compareUnsigned") \
228+
\
229+
do_intrinsic(_divideUnsigned_i, java_lang_Integer, divideUnsigned_name, int2_int_signature, F_S) \
230+
do_intrinsic(_remainderUnsigned_i, java_lang_Integer, remainderUnsigned_name, int2_int_signature, F_S) \
231+
do_name( divideUnsigned_name, "divideUnsigned") \
232+
do_intrinsic(_divideUnsigned_l, java_lang_Long, divideUnsigned_name, long2_long_signature, F_S) \
233+
do_intrinsic(_remainderUnsigned_l, java_lang_Long, remainderUnsigned_name, long2_long_signature, F_S) \
234+
do_name( remainderUnsigned_name, "remainderUnsigned") \
235+
\
230236
do_intrinsic(_numberOfLeadingZeros_i, java_lang_Integer, numberOfLeadingZeros_name,int_int_signature, F_S) \
231237
do_intrinsic(_numberOfLeadingZeros_l, java_lang_Long, numberOfLeadingZeros_name,long_int_signature, F_S) \
232238
\

‎src/hotspot/share/opto/c2compiler.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
275275
case vmIntrinsics::_reverseBytes_l:
276276
if (!Matcher::match_rule_supported(Op_ReverseBytesL)) return false;
277277
break;
278+
case vmIntrinsics::_compareUnsigned_i:
279+
if (!Matcher::match_rule_supported(Op_CmpU3)) return false;
280+
break;
281+
case vmIntrinsics::_compareUnsigned_l:
282+
if (!Matcher::match_rule_supported(Op_CmpUL3)) return false;
283+
break;
278284
case vmIntrinsics::_divideUnsigned_i:
279285
if (!Matcher::match_rule_supported(Op_UDivI)) return false;
280286
break;

‎src/hotspot/share/opto/classes.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ macro(CmpL3)
9797
macro(CmpLTMask)
9898
macro(CmpP)
9999
macro(CmpU)
100+
macro(CmpU3)
100101
macro(CmpUL)
102+
macro(CmpUL3)
101103
macro(CompareAndSwapB)
102104
macro(CompareAndSwapS)
103105
macro(CompareAndSwapI)

‎src/hotspot/share/opto/library_call.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@ bool LibraryCallKit::try_to_inline(int predicate) {
535535
case vmIntrinsics::_expand_i:
536536
case vmIntrinsics::_expand_l: return inline_bitshuffle_methods(intrinsic_id());
537537

538+
case vmIntrinsics::_compareUnsigned_i:
539+
case vmIntrinsics::_compareUnsigned_l: return inline_compare_unsigned(intrinsic_id());
540+
538541
case vmIntrinsics::_divideUnsigned_i:
539542
case vmIntrinsics::_divideUnsigned_l:
540543
case vmIntrinsics::_remainderUnsigned_i:
@@ -2247,6 +2250,22 @@ bool LibraryCallKit::inline_bitshuffle_methods(vmIntrinsics::ID id) {
22472250
return true;
22482251
}
22492252

2253+
//--------------------------inline_number_methods-----------------------------
2254+
// inline int Integer.compareUnsigned(int, int)
2255+
// inline int Long.compareUnsigned(long, long)
2256+
bool LibraryCallKit::inline_compare_unsigned(vmIntrinsics::ID id) {
2257+
Node* arg1 = argument(0);
2258+
Node* arg2 = (id == vmIntrinsics::_compareUnsigned_l) ? argument(2) : argument(1);
2259+
Node* n = NULL;
2260+
switch (id) {
2261+
case vmIntrinsics::_compareUnsigned_i: n = new CmpU3Node(arg1, arg2); break;
2262+
case vmIntrinsics::_compareUnsigned_l: n = new CmpUL3Node(arg1, arg2); break;
2263+
default: fatal_unexpected_iid(id); break;
2264+
}
2265+
set_result(_gvn.transform(n));
2266+
return true;
2267+
}
2268+
22502269
//--------------------------inline_unsigned_divmod_methods-----------------------------
22512270
// inline int Integer.divideUnsigned(int, int)
22522271
// inline int Integer.remainderUnsigned(int, int)

‎src/hotspot/share/opto/library_call.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ class LibraryCallKit : public GraphKit {
277277
bool inline_fp_range_check(vmIntrinsics::ID id);
278278
bool inline_number_methods(vmIntrinsics::ID id);
279279
bool inline_bitshuffle_methods(vmIntrinsics::ID id);
280+
bool inline_compare_unsigned(vmIntrinsics::ID id);
280281
bool inline_divmod_methods(vmIntrinsics::ID id);
281282
bool inline_reference_get();
282283
bool inline_reference_refersTo0(bool is_phantom);

‎src/hotspot/share/opto/subnode.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,12 @@ bool CmpUNode::is_index_range_check() const {
848848
Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) {
849849
if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) {
850850
switch (in(1)->Opcode()) {
851+
case Op_CmpU3: // Collapse a CmpU3/CmpI into a CmpU
852+
return new CmpUNode(in(1)->in(1),in(1)->in(2));
851853
case Op_CmpL3: // Collapse a CmpL3/CmpI into a CmpL
852854
return new CmpLNode(in(1)->in(1),in(1)->in(2));
855+
case Op_CmpUL3: // Collapse a CmpUL3/CmpI into a CmpUL
856+
return new CmpULNode(in(1)->in(1),in(1)->in(2));
853857
case Op_CmpF3: // Collapse a CmpF3/CmpI into a CmpF
854858
return new CmpFNode(in(1)->in(1),in(1)->in(2));
855859
case Op_CmpD3: // Collapse a CmpD3/CmpI into a CmpD

‎src/hotspot/share/opto/subnode.hpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ class CmpUNode : public CmpNode {
173173
bool is_index_range_check() const;
174174
};
175175

176+
//------------------------------CmpU3Node--------------------------------------
177+
// Compare 2 unsigned values, returning integer value (-1, 0 or 1).
178+
class CmpU3Node : public CmpUNode {
179+
public:
180+
CmpU3Node( Node *in1, Node *in2 ) : CmpUNode(in1,in2) {
181+
// Since it is not consumed by Bools, it is not really a Cmp.
182+
init_class_id(Class_Sub);
183+
}
184+
virtual int Opcode() const;
185+
virtual uint ideal_reg() const { return Op_RegI; }
186+
};
187+
176188
//------------------------------CmpPNode---------------------------------------
177189
// Compare 2 pointer values, returning condition codes (-1, 0 or 1).
178190
class CmpPNode : public CmpNode {
@@ -220,7 +232,19 @@ class CmpL3Node : public CmpLNode {
220232
// Since it is not consumed by Bools, it is not really a Cmp.
221233
init_class_id(Class_Sub);
222234
}
223-
virtual int Opcode() const;
235+
virtual int Opcode() const;
236+
virtual uint ideal_reg() const { return Op_RegI; }
237+
};
238+
239+
//------------------------------CmpUL3Node-------------------------------------
240+
// Compare 2 unsigned long values, returning integer value (-1, 0 or 1).
241+
class CmpUL3Node : public CmpULNode {
242+
public:
243+
CmpUL3Node( Node *in1, Node *in2 ) : CmpULNode(in1,in2) {
244+
// Since it is not consumed by Bools, it is not really a Cmp.
245+
init_class_id(Class_Sub);
246+
}
247+
virtual int Opcode() const;
224248
virtual uint ideal_reg() const { return Op_RegI; }
225249
};
226250

‎src/hotspot/share/runtime/vmStructs.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1708,11 +1708,13 @@
17081708
declare_c2_type(CmpNode, SubNode) \
17091709
declare_c2_type(CmpINode, CmpNode) \
17101710
declare_c2_type(CmpUNode, CmpNode) \
1711+
declare_c2_type(CmpU3Node, CmpUNode) \
17111712
declare_c2_type(CmpPNode, CmpNode) \
17121713
declare_c2_type(CmpNNode, CmpNode) \
17131714
declare_c2_type(CmpLNode, CmpNode) \
17141715
declare_c2_type(CmpULNode, CmpNode) \
17151716
declare_c2_type(CmpL3Node, CmpLNode) \
1717+
declare_c2_type(CmpUL3Node, CmpULNode) \
17161718
declare_c2_type(CmpFNode, CmpNode) \
17171719
declare_c2_type(CmpF3Node, CmpFNode) \
17181720
declare_c2_type(CmpDNode, CmpNode) \

‎src/java.base/share/classes/java/lang/Integer.java

+1
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,7 @@ public static int compare(int x, int y) {
15001500
* unsigned values
15011501
* @since 1.8
15021502
*/
1503+
@IntrinsicCandidate
15031504
public static int compareUnsigned(int x, int y) {
15041505
return compare(x + MIN_VALUE, y + MIN_VALUE);
15051506
}

‎src/java.base/share/classes/java/lang/Long.java

+1
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,7 @@ public static int compare(long x, long y) {
16411641
* unsigned values
16421642
* @since 1.8
16431643
*/
1644+
@IntrinsicCandidate
16441645
public static int compareUnsigned(long x, long y) {
16451646
return compare(x + MIN_VALUE, y + MIN_VALUE);
16461647
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
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
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package compiler.intrinsics;
24+
25+
import compiler.lib.ir_framework.*;
26+
import jdk.test.lib.Asserts;
27+
import jdk.test.lib.Utils;
28+
29+
/*
30+
* @test
31+
* @key randomness
32+
* @bug 8283726
33+
* @requires os.arch=="amd64" | os.arch=="x86_64"
34+
* @summary Test the intrinsics implementation of Integer/Long::compareUnsigned
35+
* @library /test/lib /
36+
* @run driver compiler.intrinsics.TestCompareUnsigned
37+
*/
38+
public class TestCompareUnsigned {
39+
static final int TRUE_VALUE = 10;
40+
static final int FALSE_VALUE = 4;
41+
42+
public static void main(String[] args) {
43+
var test = new TestFramework(TestCompareUnsigned.class);
44+
test.setDefaultWarmup(1);
45+
test.start();
46+
}
47+
48+
static int expectedResult(int x, int y) {
49+
return Integer.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE);
50+
}
51+
52+
static int expectedResult(long x, long y) {
53+
return Long.compare(x + Long.MIN_VALUE, y + Long.MIN_VALUE);
54+
}
55+
56+
@Test
57+
@IR(failOn = {IRNode.CMP_U3})
58+
@IR(counts = {IRNode.CMP_U, "1"})
59+
public int lessThanInt(int x, int y) {
60+
return Integer.compareUnsigned(x, y) < 0 ? TRUE_VALUE : FALSE_VALUE;
61+
}
62+
63+
@Test
64+
@IR(failOn = {IRNode.CMP_UL3})
65+
@IR(counts = {IRNode.CMP_UL, "1"})
66+
public int lessThanLong(long x, long y) {
67+
return Long.compareUnsigned(x, y) < 0 ? TRUE_VALUE : FALSE_VALUE;
68+
}
69+
70+
@Test
71+
@IR(counts = {IRNode.CMP_U3, "1"})
72+
public int compareInt(int x, int y) {
73+
return Integer.compareUnsigned(x, y);
74+
}
75+
76+
@Test
77+
@IR(counts = {IRNode.CMP_UL3, "1"})
78+
public int compareLong(long x, long y) {
79+
return Long.compareUnsigned(x, y);
80+
}
81+
82+
@Run(test = {"lessThanInt", "lessThanLong", "compareInt", "compareLong"})
83+
public void runTests() {
84+
var random = Utils.getRandomInstance();
85+
for (int i = 0; i < 1000; i++) {
86+
int x = random.nextInt();
87+
int y = random.nextInt();
88+
Asserts.assertEquals(lessThanInt(x, x), FALSE_VALUE);
89+
Asserts.assertEquals(compareInt(x, x), 0);
90+
Asserts.assertEquals(lessThanInt(x, y), expectedResult(x, y) < 0 ? TRUE_VALUE : FALSE_VALUE);
91+
Asserts.assertEquals(compareInt(x, y), expectedResult(x, y));
92+
}
93+
for (int i = 0; i < 1000; i++) {
94+
long x = random.nextLong();
95+
long y = random.nextLong();
96+
Asserts.assertEquals(lessThanLong(x, x), FALSE_VALUE);
97+
Asserts.assertEquals(compareLong(x, x), 0);
98+
Asserts.assertEquals(lessThanLong(x, y), expectedResult(x, y) < 0 ? TRUE_VALUE : FALSE_VALUE);
99+
Asserts.assertEquals(compareLong(x, y), expectedResult(x, y));
100+
}
101+
}
102+
}

‎test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java

+4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ public class IRNode {
172172
public static final String SUB_L = START + "SubL" + MID + END;
173173
public static final String SUB_F = START + "SubF" + MID + END;
174174
public static final String SUB_D = START + "SubD" + MID + END;
175+
public static final String CMP_U = START + "CmpU" + MID + END;
176+
public static final String CMP_UL = START + "CmpUL" + MID + END;
177+
public static final String CMP_U3 = START + "CmpU3" + MID + END;
178+
public static final String CMP_UL3 = START + "CmpUL3" + MID + END;
175179
public static final String MUL = START + "Mul(I|L|F|D)" + MID + END;
176180
public static final String MUL_I = START + "MulI" + MID + END;
177181
public static final String MUL_L = START + "MulL" + MID + END;

‎test/micro/org/openjdk/bench/java/lang/Integers.java

+18
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class Integers {
5252
@Param("500")
5353
private int size;
5454

55+
private int bound;
5556
private String[] strings;
5657
private int[] intsTiny;
5758
private int[] intsSmall;
@@ -60,6 +61,7 @@ public class Integers {
6061
@Setup
6162
public void setup() {
6263
Random r = new Random(0);
64+
bound = 50;
6365
strings = new String[size];
6466
intsTiny = new int[size];
6567
intsSmall = new int[size];
@@ -146,4 +148,20 @@ public void shiftLeft(Blackhole bh) {
146148
bh.consume(intsBig[i] << intsSmall[i]);
147149
}
148150
}
151+
152+
@Benchmark
153+
public void compareUnsignedIndirect(Blackhole bh) {
154+
for (int i = 0; i < size; i++) {
155+
int r = (Integer.compareUnsigned(intsSmall[i], bound - 16) < 0) ? 1 : 0;
156+
bh.consume(r);
157+
}
158+
}
159+
160+
@Benchmark
161+
public void compareUnsignedDirect(Blackhole bh) {
162+
for (int i = 0; i < size; i++) {
163+
int r = Integer.compareUnsigned(intsSmall[i], bound - 16);
164+
bh.consume(r);
165+
}
166+
}
149167
}

‎test/micro/org/openjdk/bench/java/lang/Longs.java

+18
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ public class Longs {
4949
@Param("500")
5050
private int size;
5151

52+
private long bound;
5253
private String[] strings;
5354
private long[] longArraySmall;
5455
private long[] longArrayBig;
5556

5657
@Setup
5758
public void setup() {
5859
var random = ThreadLocalRandom.current();
60+
bound = 20000L;
5961
strings = new String[size];
6062
longArraySmall = new long[size];
6163
longArrayBig = new long[size];
@@ -141,4 +143,20 @@ public void shiftLeft(Blackhole bh) {
141143
bh.consume(longArrayBig[i] << longArraySmall[i]);
142144
}
143145
}
146+
147+
@Benchmark
148+
public void compareUnsignedIndirect(Blackhole bh) {
149+
for (int i = 0; i < size; i++) {
150+
int r = (Long.compareUnsigned(longArraySmall[i], bound - 16) < 0) ? 1 : 0;
151+
bh.consume(r);
152+
}
153+
}
154+
155+
@Benchmark
156+
public void compareUnsignedDirect(Blackhole bh) {
157+
for (int i = 0; i < size; i++) {
158+
int r = Long.compareUnsigned(longArraySmall[i], bound - 16);
159+
bh.consume(r);
160+
}
161+
}
144162
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Jun 29, 2022

@openjdk-notifier[bot]
Please sign in to comment.