diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index c4f96e1b5a..002b84a1f2 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -18,6 +18,7 @@ INPUT_SET(NoZero) INPUT_SET(Positive) INPUT_SET(Bitwise) INPUT_SET(SelectCond) +INPUT_SET(FloatSpecial) #undef INPUT_SET @@ -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, "", ">") diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index 24a4301299..e713413e5d 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -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::infinity(), + -std::numeric_limits::infinity(), + std::numeric_limits::signaling_NaN(), + -std::numeric_limits::signaling_NaN(), + std::numeric_limits::quiet_NaN(), + -std::numeric_limits::quiet_NaN(), 0.0, -0.0, + std::numeric_limits::min(), std::numeric_limits::max(), + -std::numeric_limits::min(), + -std::numeric_limits::max(), + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() * 10.0, 1.0 / 3.0); END_INPUT_SETS() BEGIN_INPUT_SETS(float) @@ -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::infinity(), + -std::numeric_limits::infinity(), + std::numeric_limits::signaling_NaN(), + -std::numeric_limits::signaling_NaN(), + std::numeric_limits::quiet_NaN(), + -std::numeric_limits::quiet_NaN(), 0.0f, -0.0f, + std::numeric_limits::min(), std::numeric_limits::max(), + -std::numeric_limits::min(), + -std::numeric_limits::max(), + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() * 10.0f, 1.0f / 3.0f); END_INPUT_SETS() BEGIN_INPUT_SETS(double) diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 93a46d02fb..27b6bd023e 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -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 struct Op : 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 // @@ -1671,6 +1685,16 @@ class DxilConf_SM69_Vectorized { HLK_TEST(Abs, double); HLK_TEST(Sign, double); + // 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); + // Binary Comparison HLK_TEST(LessThan, int16_t);