diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index 5d668a6646..4621ad1605 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -184,10 +184,6 @@ struct HLSLHalf_t { return FromHALF((DirectX::PackedVector::XMConvertFloatToHalf(A + B))); } - HLSLHalf_t &operator+=(const HLSLHalf_t &Other) { - return *this = *this + Other; - } - HLSLHalf_t operator-(const HLSLHalf_t &Other) const { const float A = DirectX::PackedVector::XMConvertHalfToFloat(Val); const float B = DirectX::PackedVector::XMConvertHalfToFloat(Other.Val); diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 6d9005a9b2..af36b4782b 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1048,10 +1048,14 @@ template struct ExpectedBuilder { const InputSets &Inputs, uint16_t ScalarInputFlags) { UNREFERENCED_PARAMETER(ScalarInputFlags); - T DotProduct = T(); + + // Accumulate in fp32 to improve precision. + float DotProduct = 0.0f; for (size_t I = 0; I < Inputs[0].size(); ++I) { - DotProduct += Inputs[0][I] * Inputs[1][I]; + const float A = Inputs[0][I]; + const float B = Inputs[1][I]; + DotProduct += A * B; } std::vector Expected;