From 3b2c4331671e04a964d7b47a9876bc46e8a276d6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 3 May 2019 10:15:07 +1000 Subject: [PATCH] intel/compiler: remove repeated bit_size / 8 in brw mem lowering pass. Just use a variable already. Reviewed-by: Jason Ekstrand --- .../compiler/brw_nir_lower_mem_access_bit_sizes.c | 15 ++++++++------- 1 file changed, 8 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 0705c4efd82..2ec47b38999 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 @@ -179,16 +179,17 @@ lower_mem_store_bit_size(nir_builder *b, nir_intrinsic_instr *intrin) const unsigned const_offset = offset_is_const ? nir_src_as_uint(*offset_src) : 0; - assert(num_components * (bit_size / 8) <= 32); + const unsigned byte_size = bit_size / 8; + assert(num_components * byte_size <= 32); uint32_t byte_mask = 0; for (unsigned i = 0; i < num_components; i++) { - if (writemask & (1 << i)) - byte_mask |= ((1 << (bit_size / 8)) - 1) << i * (bit_size / 8); + if (writemask & (1u << i)) + byte_mask |= ((1 << byte_size) - 1) << i * byte_size; } while (byte_mask) { const int start = ffs(byte_mask) - 1; - assert(start % (bit_size / 8) == 0); + assert(start % byte_size == 0); int end; for (end = start + 1; end < bytes_written; end++) { @@ -217,9 +218,9 @@ lower_mem_store_bit_size(nir_builder *b, nir_intrinsic_instr *intrin) } const unsigned store_bytes = store_comps * (store_bit_size / 8); - assert(store_bytes % (bit_size / 8) == 0); - const unsigned store_first_src_comp = start / (bit_size / 8); - const unsigned store_src_comps = store_bytes / (bit_size / 8); + assert(store_bytes % byte_size == 0); + const unsigned store_first_src_comp = start / byte_size; + const unsigned store_src_comps = store_bytes / byte_size; assert(store_first_src_comp + store_src_comps <= num_components); unsigned src_swiz[4] = { 0, }; -- 2.30.2