Skip to content

Commit 149ec16

Browse files
spirv-val: Use validation_state.cpp helpers (#6478)
two spots found not using the helpers
1 parent 31a9403 commit 149ec16

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

source/val/validate_memory.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,11 +2126,10 @@ spv_result_t ValidateArrayLength(ValidationState_t& state,
21262126
// Result type must be a 32- or 64-bit unsigned int.
21272127
// 64-bit requires CapabilityShader64BitIndexingEXT or a pipeline/shader
21282128
// flag and is validated in VVL.
2129-
auto result_type = state.FindDef(inst->type_id());
2130-
if (result_type->opcode() != spv::Op::OpTypeInt ||
2131-
!(result_type->GetOperandAs<uint32_t>(1) == 32 ||
2132-
result_type->GetOperandAs<uint32_t>(1) == 64) ||
2133-
result_type->GetOperandAs<uint32_t>(2) != 0) {
2129+
const uint32_t result_type_id = inst->type_id();
2130+
const uint32_t result_type_width = state.GetBitWidth(inst->type_id());
2131+
if (!state.IsIntScalarTypeWithSignedness(result_type_id, 0) ||
2132+
(result_type_width != 32 && result_type_width != 64)) {
21342133
return state.diag(SPV_ERROR_INVALID_ID, inst)
21352134
<< "The Result Type of Op" << spvOpcodeString(opcode) << " <id> "
21362135
<< state.getIdName(inst->id())
@@ -2204,10 +2203,9 @@ spv_result_t ValidateCooperativeMatrixLengthNV(ValidationState_t& state,
22042203
const Instruction* inst) {
22052204
const spv::Op opcode = inst->opcode();
22062205
// Result type must be a 32-bit unsigned int.
2207-
auto result_type = state.FindDef(inst->type_id());
2208-
if (result_type->opcode() != spv::Op::OpTypeInt ||
2209-
result_type->GetOperandAs<uint32_t>(1) != 32 ||
2210-
result_type->GetOperandAs<uint32_t>(2) != 0) {
2206+
const uint32_t result_type_id = inst->type_id();
2207+
if (!state.IsIntScalarTypeWithSignedness(result_type_id, 0) ||
2208+
state.GetBitWidth(inst->type_id()) != 32) {
22112209
return state.diag(SPV_ERROR_INVALID_ID, inst)
22122210
<< "The Result Type of Op" << spvOpcodeString(opcode) << " <id> "
22132211
<< state.getIdName(inst->id())

0 commit comments

Comments
 (0)