Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hotspot/share/adlc/formssel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4196,6 +4196,7 @@ int MatchRule::is_expensive() const {
if( strcmp(opType,"AtanD")==0 ||
strcmp(opType,"DivD")==0 ||
strcmp(opType,"DivF")==0 ||
strcmp(opType,"DivHF")==0 ||
strcmp(opType,"DivI")==0 ||
strcmp(opType,"Log10D")==0 ||
strcmp(opType,"ModD")==0 ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ public static Float16 valueOf(long value) {
*/
@ForceInline
public static Float16 valueOf(float f) {
short hf = floatToFloat16(f);
return new Float16(hf);
return new Float16(floatToFloat16(f));
}

/**
Expand Down Expand Up @@ -1200,14 +1199,22 @@ public static Float16 divide(Float16 dividend, Float16 divisor) {
* @see Math#sqrt(double)
*/
public static Float16 sqrt(Float16 radicand) {
// Rounding path of sqrt(Float16 -> double) -> Float16 is fine
// for preserving the correct final value. The conversion
// Float16 -> double preserves the exact numerical value. The
// conversion of double -> Float16 also benefits from the
// 2p+2 property of IEEE 754 arithmetic.
short res = Float16Math.sqrt(float16ToRawShortBits(radicand),
(f16) -> float16ToRawShortBits(valueOf(Math.sqrt(shortBitsToFloat16(f16).doubleValue()))));
return shortBitsToFloat16(res);
// Explicitly unbox float16 radicand as intrinsic expects
// to receive short type arguments holding IEEE 754 binary16
// value.
short unboxed_radicand = float16ToRawShortBits(radicand);
short retval = Float16Math.sqrt(unboxed_radicand,
(f16) -> {
// Rounding path of sqrt(Float16 -> double) -> Float16 is fine
// for preserving the correct final value. The conversion
// Float16 -> double preserves the exact numerical value. The
// conversion of double -> Float16 also benefits from the
// 2p+2 property of IEEE 754 arithmetic.
double res = Math.sqrt(float16ToFloat(f16));
return float16ToRawShortBits(valueOf(res));
}
);
return shortBitsToFloat16(retval);
}

/**
Expand Down Expand Up @@ -1409,14 +1416,18 @@ public static Float16 fma(Float16 a, Float16 b, Float16 c) {
* harmless.
*/

// product is numerically exact in float before the cast to
// double; not necessary to widen to double before the
// multiply.
short fa = float16ToRawShortBits(a);
short fb = float16ToRawShortBits(b);
short fc = float16ToRawShortBits(c);
short res = Float16Math.fma(fa, fb, fc,
// Explicitly unbox float16 values as intrinsic expects
// to receive short type arguments holding IEEE 754 binary16
// values.
short unboxed_a = float16ToRawShortBits(a);
short unboxed_b = float16ToRawShortBits(b);
short unboxed_c = float16ToRawShortBits(c);

short res = Float16Math.fma(unboxed_a, unboxed_b, unboxed_c,
(f16a, f16b, f16c) -> {
// product is numerically exact in float before the cast to
// double; not necessary to widen to double before the
// multiply.
double product = (double)(float16ToFloat(f16a) * float16ToFloat(f16b));
return float16ToRawShortBits(valueOf(product + float16ToFloat(f16c)));
});
Expand Down