8283726: x86_64 intrinsics for compareUnsigned method in Integer and Long

Reviewed-by: kvn, jbhateja
This commit is contained in:
Quan Anh Mai 2022-06-29 10:34:05 +00:00 committed by Jatin Bhateja
parent b96ba19807
commit 108cd69516
15 changed files with 271 additions and 11 deletions

View file

@ -49,6 +49,7 @@ public class Longs {
@Param("500")
private int size;
private long bound;
private String[] strings;
private long[] longArraySmall;
private long[] longArrayBig;
@ -56,6 +57,7 @@ public class Longs {
@Setup
public void setup() {
var random = ThreadLocalRandom.current();
bound = 20000L;
strings = new String[size];
longArraySmall = new long[size];
longArrayBig = new long[size];
@ -141,4 +143,20 @@ public class Longs {
bh.consume(longArrayBig[i] << longArraySmall[i]);
}
}
@Benchmark
public void compareUnsignedIndirect(Blackhole bh) {
for (int i = 0; i < size; i++) {
int r = (Long.compareUnsigned(longArraySmall[i], bound - 16) < 0) ? 1 : 0;
bh.consume(r);
}
}
@Benchmark
public void compareUnsignedDirect(Blackhole bh) {
for (int i = 0; i < size; i++) {
int r = Long.compareUnsigned(longArraySmall[i], bound - 16);
bh.consume(r);
}
}
}