intel/compiler: use bitset instead of opencoding a 32-bit bitset. (v2)

In the future I want to expand this to 128-bits, for vec16 support, so
lets just put the code in place to use bitset ranges now.

v2: just declare the bitset to be the max of what we should ever see
and change assert to reflect it.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Dave Airlie 2019-05-03 10:17:54 +10:00
parent 3b2c433167
commit 4efd04ab18

View file

@ -180,20 +180,23 @@ lower_mem_store_bit_size(nir_builder *b, nir_intrinsic_instr *intrin)
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 */
@ -233,7 +236,7 @@ lower_mem_store_bit_size(nir_builder *b, nir_intrinsic_instr *intrin)
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);