diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 04b2e2d4753..d2f037df6ec 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -1658,25 +1658,20 @@ void C2_MacroAssembler::round_double_mode(FloatRegister dst, FloatRegister src, // otherwise return +/- 1.0 using sign of input. // one - gives us a floating-point 1.0 (got from matching rule) // bool is_double - specifies single or double precision operations will be used. -void C2_MacroAssembler::signum_fp(FloatRegister dst, FloatRegister src, FloatRegister one, bool is_double) { - Register tmp1 = t0; - +void C2_MacroAssembler::signum_fp(FloatRegister dst, FloatRegister one, bool is_double) { Label done; - is_double ? fclass_d(tmp1, src) - : fclass_s(tmp1, src); - - is_double ? fmv_d(dst, src) - : fmv_s(dst, src); + is_double ? fclass_d(t0, dst) + : fclass_s(t0, dst); // check if input is -0, +0, signaling NaN or quiet NaN - andi(tmp1, tmp1, fclass_mask::zero | fclass_mask::nan); + andi(t0, t0, fclass_mask::zero | fclass_mask::nan); - bnez(tmp1, done); + bnez(t0, done); // use floating-point 1.0 with a sign of input - is_double ? fsgnj_d(dst, one, src) - : fsgnj_s(dst, one, src); + is_double ? fsgnj_d(dst, one, dst) + : fsgnj_s(dst, one, dst); bind(done); } diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp index 5c87a0d3af0..32fda93c3cb 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp @@ -157,8 +157,7 @@ void round_double_mode(FloatRegister dst, FloatRegister src, int round_mode, Register tmp1, Register tmp2, Register tmp3); - void signum_fp(FloatRegister dst, FloatRegister src, FloatRegister one, - bool is_double); + void signum_fp(FloatRegister dst, FloatRegister one, bool is_double); // intrinsic methods implemented by rvv instructions void string_equals_v(Register r1, Register r2, diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 2e853c2acce..dfd4c33d8c2 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -7601,22 +7601,20 @@ instruct copySignF_reg(fRegF dst, fRegF src1, fRegF src2) %{ ins_pipe(fp_dop_reg_reg_s); %} -instruct signumD_reg(fRegD dst, fRegD src, immD zero, fRegD one) %{ - match(Set dst (SignumD src (Binary zero one))); - format %{ "signumD $dst, $src" %} +instruct signumD_reg(fRegD dst, immD zero, fRegD one) %{ + match(Set dst (SignumD dst (Binary zero one))); + format %{ "signumD $dst, $dst" %} ins_encode %{ - __ signum_fp(as_FloatRegister($dst$$reg), as_FloatRegister($src$$reg), - as_FloatRegister($one$$reg), true /* is_double */); + __ signum_fp(as_FloatRegister($dst$$reg), as_FloatRegister($one$$reg), true /* is_double */); %} ins_pipe(pipe_class_default); %} -instruct signumF_reg(fRegF dst, fRegF src, immF zero, fRegF one) %{ - match(Set dst (SignumF src (Binary zero one))); - format %{ "signumF $dst, $src" %} +instruct signumF_reg(fRegF dst, immF zero, fRegF one) %{ + match(Set dst (SignumF dst (Binary zero one))); + format %{ "signumF $dst, $dst" %} ins_encode %{ - __ signum_fp(as_FloatRegister($dst$$reg), as_FloatRegister($src$$reg), - as_FloatRegister($one$$reg), false /* is_double */); + __ signum_fp(as_FloatRegister($dst$$reg), as_FloatRegister($one$$reg), false /* is_double */); %} ins_pipe(pipe_class_default); %} diff --git a/test/hotspot/jtreg/compiler/intrinsics/math/TestSignumIntrinsic.java b/test/hotspot/jtreg/compiler/intrinsics/math/TestSignumIntrinsic.java index 65d261bb8e2..a5546ba9e5c 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/math/TestSignumIntrinsic.java +++ b/test/hotspot/jtreg/compiler/intrinsics/math/TestSignumIntrinsic.java @@ -35,6 +35,10 @@ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:-UseSignumIntrinsic -XX:+UseCopySignIntrinsic * compiler.intrinsics.math.TestSignumIntrinsic + * @run main/othervm + * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -Xcomp -XX:+UseSignumIntrinsic + * compiler.intrinsics.math.TestSignumIntrinsic */ package compiler.intrinsics.math;