offset_is_const ? nir_src_as_uint(*offset_src) : 0;
const unsigned byte_size = bit_size / 8;
- assert(num_components * byte_size <= 32);
- uint32_t byte_mask = 0;
+ assert(byte_size <= sizeof(uint64_t));
+
+ BITSET_DECLARE(mask, NIR_MAX_VEC_COMPONENTS * sizeof(uint64_t));
+ BITSET_ZERO(mask);
+
for (unsigned i = 0; i < num_components; i++) {
if (writemask & (1u << i))
- byte_mask |= ((1 << byte_size) - 1) << i * byte_size;
+ BITSET_SET_RANGE(mask, i * byte_size, ((i + 1) * byte_size) - 1);
}
- while (byte_mask) {
- const int start = ffs(byte_mask) - 1;
+ while (BITSET_FFS(mask) != 0) {
+ const int start = BITSET_FFS(mask) - 1;
assert(start % byte_size == 0);
int end;
for (end = start + 1; end < bytes_written; end++) {
- if (!(byte_mask & (1 << end)))
+ if (!(BITSET_TEST(mask, end)))
break;
}
/* The size of the current contiguous chunk in bytes */
dup_mem_intrinsic(b, intrin, packed, start,
store_comps, store_bit_size, store_align);
- byte_mask &= ~(((1u << store_bytes) - 1) << start);
+ BITSET_CLEAR_RANGE(mask, start, (start + store_bytes - 1));
}
nir_instr_remove(&intrin->instr);