spirv: Use a single path for OpSpecConstantOp of OpVectorShuffle
Now that nir_const_value is a scalar, there's no reason why we need multiple paths here and it's just extra paths to keep working. While we're here, we also add a vtn_fail_if check that component indices are in-bounds. Reviewed-by: Karol Herbst <kherbst@redhat.com>
This commit is contained in:
@@ -1793,48 +1793,30 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
|
|||||||
vtn_assert(bit_size == bit_size0 && bit_size == bit_size1);
|
vtn_assert(bit_size == bit_size0 && bit_size == bit_size1);
|
||||||
(void)bit_size0; (void)bit_size1;
|
(void)bit_size0; (void)bit_size1;
|
||||||
|
|
||||||
if (bit_size == 64) {
|
nir_const_value undef = { .u64 = 0xdeadbeefdeadbeef };
|
||||||
uint64_t u64[8];
|
nir_const_value combined[NIR_MAX_VEC_COMPONENTS * 2];
|
||||||
|
|
||||||
if (v0->value_type == vtn_value_type_constant) {
|
if (v0->value_type == vtn_value_type_constant) {
|
||||||
for (unsigned i = 0; i < len0; i++)
|
for (unsigned i = 0; i < len0; i++)
|
||||||
u64[i] = v0->constant->values[0][i].u64;
|
combined[i] = v0->constant->values[0][i];
|
||||||
}
|
}
|
||||||
if (v1->value_type == vtn_value_type_constant) {
|
if (v1->value_type == vtn_value_type_constant) {
|
||||||
for (unsigned i = 0; i < len1; i++)
|
for (unsigned i = 0; i < len1; i++)
|
||||||
u64[len0 + i] = v1->constant->values[0][i].u64;
|
combined[len0 + i] = v1->constant->values[0][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0, j = 0; i < count - 6; i++, j++) {
|
for (unsigned i = 0, j = 0; i < count - 6; i++, j++) {
|
||||||
uint32_t comp = w[i + 6];
|
uint32_t comp = w[i + 6];
|
||||||
|
if (comp == (uint32_t)-1) {
|
||||||
/* If component is not used, set the value to a known constant
|
/* If component is not used, set the value to a known constant
|
||||||
* to detect if it is wrongly used.
|
* to detect if it is wrongly used.
|
||||||
*/
|
*/
|
||||||
if (comp == (uint32_t)-1)
|
val->constant->values[0][j] = undef;
|
||||||
val->constant->values[0][j].u64 = 0xdeadbeefdeadbeef;
|
|
||||||
else
|
|
||||||
val->constant->values[0][j].u64 = u64[comp];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* This is for both 32-bit and 16-bit values */
|
vtn_fail_if(comp >= len0 + len1,
|
||||||
uint32_t u32[8];
|
"All Component literals must either be FFFFFFFF "
|
||||||
if (v0->value_type == vtn_value_type_constant) {
|
"or in [0, N - 1] (inclusive).");
|
||||||
for (unsigned i = 0; i < len0; i++)
|
val->constant->values[0][j] = combined[comp];
|
||||||
u32[i] = v0->constant->values[0][i].u32;
|
|
||||||
}
|
|
||||||
if (v1->value_type == vtn_value_type_constant) {
|
|
||||||
for (unsigned i = 0; i < len1; i++)
|
|
||||||
u32[len0 + i] = v1->constant->values[0][i].u32;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned i = 0, j = 0; i < count - 6; i++, j++) {
|
|
||||||
uint32_t comp = w[i + 6];
|
|
||||||
/* If component is not used, set the value to a known constant
|
|
||||||
* to detect if it is wrongly used.
|
|
||||||
*/
|
|
||||||
if (comp == (uint32_t)-1)
|
|
||||||
val->constant->values[0][j].u32 = 0xdeadbeef;
|
|
||||||
else
|
|
||||||
val->constant->values[0][j].u32 = u32[comp];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user