Skip to content

Commit 45bf588

Browse files
committed
Address comments
1 parent 9cc7e54 commit 45bf588

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

tools/clang/unittests/HLSLExec/LinAlgTests.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,23 +232,25 @@ static VariantCompType makeExpected(ComponentType CompType, int32_t M,
232232
int32_t N, float StartingVal,
233233
bool Increment = true,
234234
bool Transpose = false) {
235-
int32_t NumElements = M * N;
235+
const size_t NumElements = M * N;
236236
std::vector<float> Floats(NumElements);
237237
std::vector<int32_t> Ints(NumElements);
238238
std::vector<HLSLHalf_t> Halfs(NumElements);
239239

240-
for (int32_t I = 0; I < M; ++I) {
241-
for (int32_t J = 0; J < N; ++J) {
242-
int32_t Value = I * M + J;
243-
int32_t Idx = Transpose ? J * N + I : Value;
240+
for (size_t I = 0; I < M; ++I) {
241+
for (size_t J = 0; J < N; ++J) {
242+
size_t Value = I * M + J;
243+
size_t Idx = Transpose ? J * N + I : Value;
244244
switch (CompType) {
245245
case ComponentType::F32:
246246
Floats[Idx] = StartingVal + static_cast<float>(Increment ? Value : 0);
247247
break;
248248
case ComponentType::I32:
249-
DXASSERT(StartingVal < static_cast<float>(INT_MAX),
249+
VERIFY_IS_TRUE(StartingVal < static_cast<float>(std::numeric_limits<int32_t>::max()),
250250
"Value too large to cast to int32_t");
251-
Ints[Idx] = static_cast<int32_t>(StartingVal) + (Increment ? Value : 0);
251+
VERIFY_IS_TRUE(StartingVal > static_cast<float>(std::numeric_limits<int32_t>::min()),
252+
"Value too small to cast to int32_t");
253+
Ints[Idx] = static_cast<int32_t>(StartingVal) + static_cast<int32_t>(Increment ? Value : 0);
252254
break;
253255
case ComponentType::F16: {
254256
// Downcasting is safe here since HLSLHalf_t will clamp if F is too
@@ -257,6 +259,8 @@ static VariantCompType makeExpected(ComponentType CompType, int32_t M,
257259
Halfs[Idx] = HLSLHalf_t(F);
258260
break;
259261
}
262+
default:
263+
VERIFY_IS_TRUE(false, "Unable to fill unexpected ComponentType");
260264
}
261265
}
262266
}
@@ -269,7 +273,7 @@ static VariantCompType makeExpected(ComponentType CompType, int32_t M,
269273
case ComponentType::F16:
270274
return Halfs;
271275
default:
272-
DXASSERT(false, "Unable to fill unexpected ComponentType");
276+
VERIFY_IS_TRUE(false, "Unable to fill unexpected ComponentType");
273277
return Floats;
274278
}
275279
}

0 commit comments

Comments
 (0)