bool upper)
{
unsigned type_size = nir_alu_type_get_type_size(ins->src_types[src]) / 8;
- unsigned max_comp = 16 / type_size;
+ unsigned type_shift = util_logbase2(type_size);
+ unsigned max_comp = mir_components_for_type(ins->src_types[src]);
unsigned comp_mask = mir_from_bytemask(mir_round_bytemask_up(
mir_bytemask_of_read_components_index(ins, src),
type_size * 8),
memcpy(&bundle_constants[i], constantp, type_size);
*bundle_constant_mask |= type_mask << best_place;
- comp_mapping[comp] = best_place / type_size;
+ comp_mapping[comp] = best_place >> type_shift;
}
return true;
* = 1 << (7 - log2(sz))
*/
+static unsigned
+mir_components_for_bits(unsigned bits)
+{
+ return 1 << (7 - util_logbase2(bits));
+}
+
unsigned
mir_components_for_type(nir_alu_type T)
{
unsigned sz = nir_alu_type_get_type_size(T);
- return 1 << (7 - util_logbase2(sz));
+ return mir_components_for_bits(sz);
}
uint16_t
{
unsigned bytes = bits / 8;
unsigned maxmask = mask_of(bytes);
- unsigned channels = 16 / bytes;
+ unsigned channels = mir_components_for_bits(bits);
for (unsigned c = 0; c < channels; ++c) {
unsigned submask = maxmask << (c * bytes);
* (16/bytes), which simplifies to 8/bytes = 8 / (bits / 8) = 64 / bits
* */
- unsigned threshold = 64 / type_size;
+ unsigned threshold = mir_components_for_bits(type_size) >> 1;
/* How many components did we shift over? */
unsigned zeroes = __builtin_ctz(ins->mask);