8327147: Improve performance of Math ceil, floor, and rint for x86

Reviewed-by: jbhateja, sviswanathan, dlong
This commit is contained in:
vamsi-parasa 2024-03-07 21:44:46 +00:00 committed by Sandhya Viswanathan
parent 972e81d1ad
commit 7c5e6e74c8
3 changed files with 9 additions and 12 deletions

View File

@ -6135,7 +6135,7 @@ void Assembler::smovl() {
void Assembler::roundsd(XMMRegister dst, XMMRegister src, int32_t rmode) {
assert(VM_Version::supports_sse4_1(), "");
InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
int encode = simd_prefix_and_encode(dst, src, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int24(0x0B, (0xC0 | encode), (unsigned char)rmode);
}

View File

@ -3874,22 +3874,14 @@ instruct roundD_reg(legRegD dst, legRegD src, immU8 rmode) %{
ins_cost(150);
ins_encode %{
assert(UseSSE >= 4, "required");
if ((UseAVX == 0) && ($dst$$XMMRegister != $src$$XMMRegister)) {
__ pxor($dst$$XMMRegister, $dst$$XMMRegister);
}
__ roundsd($dst$$XMMRegister, $src$$XMMRegister, $rmode$$constant);
%}
ins_pipe(pipe_slow);
%}
instruct roundD_mem(legRegD dst, memory src, immU8 rmode) %{
match(Set dst (RoundDoubleMode (LoadD src) rmode));
format %{ "roundsd $dst,$src" %}
ins_cost(150);
ins_encode %{
assert(UseSSE >= 4, "required");
__ roundsd($dst$$XMMRegister, $src$$Address, $rmode$$constant);
%}
ins_pipe(pipe_slow);
%}
instruct roundD_imm(legRegD dst, immD con, immU8 rmode) %{
match(Set dst (RoundDoubleMode con rmode));
format %{ "roundsd $dst,[$constantaddress]\t# load from constant table: double=$con" %}

View File

@ -141,6 +141,11 @@ public class MathBench {
return Math.ceil(double4Dot1);
}
@Benchmark
public double addCeilFloorDouble() {
return Math.ceil(double4Dot1) + Math.floor(double4Dot1);
}
@Benchmark
public double copySignDouble() {
return Math.copySign(double81, doubleNegative12);