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
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/divnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,12 @@ const Type* DivHFNode::Value(PhaseGVN* phase) const {
return t1;
}

// If divisor is a constant and not zero, divide them numbers
// If divisor is a constant and not zero, divide the numbers
if (t1->base() == Type::HalfFloatCon &&
t2->base() == Type::HalfFloatCon &&
t2->getf() != 0.0) {
// could be negative zero
return TypeH::make(t1->getf()/t2->getf());
return TypeH::make(t1->getf() / t2->getf());
}

// If the dividend is a constant zero
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/opto/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,20 +1441,20 @@ bool TypeF::empty(void) const {

//=============================================================================
// Convenience common pre-built types.
const TypeH *TypeH::MAX; // Half float max
const TypeH *TypeH::MIN; // Half float min
const TypeH *TypeH::ZERO; // Half float zero
const TypeH *TypeH::ONE; // Half float one
const TypeH *TypeH::POS_INF; // Half float positive infinity
const TypeH *TypeH::NEG_INF; // Half float negative infinity
const TypeH* TypeH::MAX; // Half float max
const TypeH* TypeH::MIN; // Half float min
const TypeH* TypeH::ZERO; // Half float zero
const TypeH* TypeH::ONE; // Half float one
const TypeH* TypeH::POS_INF; // Half float positive infinity
const TypeH* TypeH::NEG_INF; // Half float negative infinity

//------------------------------make-------------------------------------------
// Create a halffloat constant
const TypeH *TypeH::make(short f) {
const TypeH* TypeH::make(short f) {
return (TypeH*)(new TypeH(f))->hashcons();
}

const TypeH *TypeH::make(float f) {
const TypeH* TypeH::make(float f) {
assert(StubRoutines::f2hf_adr() != nullptr, "");
short hf = StubRoutines::f2hf(f);
return (TypeH*)(new TypeH(hf))->hashcons();
Expand Down
22 changes: 11 additions & 11 deletions src/hotspot/share/opto/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ class TypeH : public Type {
public:
const short _f; // Half Float constant

static const TypeH *make(float f);
static const TypeH *make(short f);
static const TypeH* make(float f);
static const TypeH* make(short f);

virtual bool is_finite() const; // Has a finite value
virtual bool is_nan() const; // Is not a number (NaN)
Expand All @@ -551,12 +551,12 @@ class TypeH : public Type {
virtual const Type *xmeet(const Type *t) const;
virtual const Type *xdual() const; // Compute dual right now.
// Convenience common pre-built types.
static const TypeH *MAX;
static const TypeH *MIN;
static const TypeH *ZERO; // positive zero only
static const TypeH *ONE;
static const TypeH *POS_INF;
static const TypeH *NEG_INF;
static const TypeH* MAX;
static const TypeH* MIN;
static const TypeH* ZERO; // positive zero only
static const TypeH* ONE;
static const TypeH* POS_INF;
static const TypeH* NEG_INF;
#ifndef PRODUCT
virtual void dump2(Dict &d, uint depth, outputStream *st) const;
#endif
Expand Down Expand Up @@ -2020,18 +2020,18 @@ inline const TypeLong *Type::isa_long() const {
return ( _base == Long ? (TypeLong*)this : nullptr);
}

inline const TypeH *Type::isa_half_float() const {
inline const TypeH* Type::isa_half_float() const {
return ((_base == HalfFloatTop ||
_base == HalfFloatCon ||
_base == HalfFloatBot) ? (TypeH*)this : nullptr);
}

inline const TypeH *Type::is_half_float_constant() const {
inline const TypeH* Type::is_half_float_constant() const {
assert( _base == HalfFloatCon, "Not a Float" );
return (TypeH*)this;
}

inline const TypeH *Type::isa_half_float_constant() const {
inline const TypeH* Type::isa_half_float_constant() const {
return ( _base == HalfFloatCon ? (TypeH*)this : nullptr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class TestFloat16ScalarOperations {
private static final Float16 NEGATIVE_MAX_VALUE = valueOf(-0x1.ffcP+15f);
private static final Float16 LT_MAX_HALF_ULP = Float16.valueOf(14.0f);
private static final Float16 MAX_HALF_ULP = Float16.valueOf(16.0f);
private static final Float16 SIGNALING_NAN = shortBitsToFloat16((short)31807);

public static void main(String args[]) {
TestFramework.runWithFlags("--add-modules=jdk.incubator.vector");
Expand Down Expand Up @@ -449,6 +450,7 @@ public void testMulConstantFolding() {
public void testSqrtConstantFolding() {
// If the argument is NaN or less than zero, then the result is NaN.
assertResult(sqrt(Float16.NaN).floatValue(), Float.NaN, "testSqrtConstantFolding");
assertResult(sqrt(SIGNALING_NAN).floatValue(), Float.NaN, "testSqrtConstantFolding");

// If the argument is positive infinity, then the result is positive infinity.
assertResult(sqrt(Float16.POSITIVE_INFINITY).floatValue(), Float.POSITIVE_INFINITY, "testSqrtConstantFolding");
Expand All @@ -467,8 +469,12 @@ public void testSqrtConstantFolding() {
public void testFMAConstantFolding() {
// If any argument is NaN, the result is NaN.
assertResult(fma(Float16.NaN, valueOf(2.0f), valueOf(3.0f)).floatValue(), Float.NaN, "testFMAConstantFolding");
assertResult(fma(SIGNALING_NAN, valueOf(2.0f), valueOf(3.0f)).floatValue(), Float.NaN, "testFMAConstantFolding");
assertResult(fma(valueOf(2.0f), Float16.NaN, valueOf(3.0f)).floatValue(), Float.NaN, "testFMAConstantFolding");
assertResult(fma(valueOf(2.0f), valueOf(3.0f), Float16.NaN).floatValue(), Float.NaN, "testFMAConstantFolding");

assertResult(fma(shortBitsToFloat16(Float.floatToFloat16(2.0f)),
shortBitsToFloat16(Float.floatToFloat16(3.0f)),
Float16.NaN).floatValue(), Float.NaN, "testFMAConstantFolding");

// If one of the first two arguments is infinite and the other is zero, the result is NaN.
assertResult(fma(Float16.POSITIVE_INFINITY, POSITIVE_ZERO, valueOf(2.0f)).floatValue(), Float.NaN, "testFMAConstantFolding");
Expand Down