Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions tools/clang/unittests/HLSLExec/LongVectorOps.def
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ INPUT_SET(NoZero)
INPUT_SET(Positive)
INPUT_SET(Bitwise)
INPUT_SET(SelectCond)
INPUT_SET(FloatSpecial)

#undef INPUT_SET

Expand Down Expand Up @@ -125,6 +126,10 @@ OP_DEFAULT(UnaryMath, Log10, 1, "log10", "")
OP_DEFAULT(UnaryMath, Log2, 1, "log2", "")
OP_DEFAULT_DEFINES(UnaryMath, Frexp, 1, "TestFrexp", "", " -DFUNC_FREXP=1")

OP_DEFAULT(FloatSpecial, IsFinite, 1, "isfinite", "")
OP_DEFAULT(FloatSpecial, IsInf, 1, "isinf", "")
OP_DEFAULT(FloatSpecial, IsNan, 1, "isnan", "")

OP_DEFAULT(BinaryComparison, LessThan, 2, "", "<")
OP_DEFAULT(BinaryComparison, LessEqual, 2, "", "<=")
OP_DEFAULT(BinaryComparison, GreaterThan, 2, "", ">")
Expand Down
25 changes: 25 additions & 0 deletions tools/clang/unittests/HLSLExec/LongVectorTestData.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,20 @@ INPUT_SET(InputSet::RangeOne, 0.331, 0.727, -0.957, 0.677, -0.025, 0.495, 0.855,
INPUT_SET(InputSet::Positive, 1.0, 1.0, 342.0, 0.01, 5531.0, 0.01, 1.0, 0.01,
331.2330, 3250.01);
INPUT_SET(InputSet::SelectCond, 0.0, 1.0);
// HLSLHalf_t has a constructor which accepts a float and converts it to half
// precision by clamping to the representable range via
// DirectX::PackedVector::XMConvertFloatToHalf.
INPUT_SET(InputSet::FloatSpecial, std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::signaling_NaN(),
-std::numeric_limits<float>::signaling_NaN(),
std::numeric_limits<float>::quiet_NaN(),
-std::numeric_limits<float>::quiet_NaN(), 0.0, -0.0,
std::numeric_limits<float>::min(), std::numeric_limits<float>::max(),
-std::numeric_limits<float>::min(),
-std::numeric_limits<float>::max(),
std::numeric_limits<float>::denorm_min(),
std::numeric_limits<float>::denorm_min() * 10.0, 1.0 / 3.0);
END_INPUT_SETS()

BEGIN_INPUT_SETS(float)
Expand All @@ -364,6 +378,17 @@ INPUT_SET(InputSet::RangeOne, 0.727f, 0.331f, -0.957f, 0.677f, -0.025f, 0.495f,
INPUT_SET(InputSet::Positive, 1.0f, 1.0f, 65535.0f, 0.01f, 5531.0f, 0.01f, 1.0f,
0.01f, 331.2330f, 3250.01f);
INPUT_SET(InputSet::SelectCond, 0.0f, 1.0f);
INPUT_SET(InputSet::FloatSpecial, std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::signaling_NaN(),
-std::numeric_limits<float>::signaling_NaN(),
std::numeric_limits<float>::quiet_NaN(),
-std::numeric_limits<float>::quiet_NaN(), 0.0f, -0.0f,
std::numeric_limits<float>::min(), std::numeric_limits<float>::max(),
-std::numeric_limits<float>::min(),
-std::numeric_limits<float>::max(),
std::numeric_limits<float>::denorm_min(),
std::numeric_limits<float>::denorm_min() * 10.0f, 1.0f / 3.0f);
END_INPUT_SETS()

BEGIN_INPUT_SETS(double)
Expand Down
24 changes: 24 additions & 0 deletions tools/clang/unittests/HLSLExec/LongVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,20 @@ STRICT_OP_1(OpType::LoadAndStore_DT_SB_SRV, (A));
STRICT_OP_1(OpType::LoadAndStore_RD_SB_UAV, (A));
STRICT_OP_1(OpType::LoadAndStore_RD_SB_SRV, (A));

//
// Float Ops
//

#define FLOAT_SPECIAL_OP(OP, IMPL) \
template <typename T> struct Op<OP, T, 1> : StrictValidation { \
HLSLBool_t operator()(T A) { return IMPL; } \
};

FLOAT_SPECIAL_OP(OpType::IsFinite, (std::isfinite(A)));
FLOAT_SPECIAL_OP(OpType::IsInf, (std::isinf(A)));
FLOAT_SPECIAL_OP(OpType::IsNan, (std::isnan(A)));
#undef FLOAT_SPECIAL_OP

//
// dispatchTest
//
Expand Down Expand Up @@ -1671,6 +1685,16 @@ class DxilConf_SM69_Vectorized {
HLK_TEST(Abs, double);
HLK_TEST(Sign, double);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Float Special

// Float Special

HLK_TEST(IsFinite, HLSLHalf_t);
HLK_TEST(IsInf, HLSLHalf_t);
HLK_TEST(IsNan, HLSLHalf_t);

HLK_TEST(IsFinite, float);
HLK_TEST(IsInf, float);
HLK_TEST(IsNan, float);
Copy link
Contributor

@alsepkow alsepkow Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The other test cases are organized in groups by input type

Suggested change
HLK_TEST(IsNan, float);
HLK_TEST(IsInf, HLSLHalf_t);
HLK_TEST(IsFinite, HLSLHalf_t);
HLK_TEST(IsNan, HLSLHalf_t);
HLK_TEST(IsInf, float);
HLK_TEST(IsFinite, float);
HLK_TEST(IsNan, float);


// Binary Comparison

HLK_TEST(LessThan, int16_t);
Expand Down