diff options
author | Dave Airlie <[email protected]> | 2019-05-03 10:17:54 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2019-05-15 07:10:34 +1000 |
commit | 4efd04ab182e7dad1d77f20ecdd03099330ea9f0 (patch) | |
tree | 6db4e955d7009e5809f484fac6cc48c08b4fd5ad | |
parent | 3b2c4331671e04a964d7b47a9876bc46e8a276d6 (diff) |
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 <[email protected]>
-rw-r--r-- | src/intel/compiler/brw_nir_lower_mem_access_bit_sizes.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/intel/compiler/brw_nir_lower_mem_access_bit_sizes.c b/src/intel/compiler/brw_nir_lower_mem_access_bit_sizes.c index 2ec47b38999..342cf9ede87 100644 --- a/src/intel/compiler/brw_nir_lower_mem_access_bit_sizes.c +++ b/src/intel/compiler/brw_nir_lower_mem_access_bit_sizes.c @@ -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); |