Mesa (master): pan/mdg: Eliminate remaining divisions from compiler

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 21 22:44:32 UTC 2020


Module: Mesa
Branch: master
Commit: e85b6c4ab130670916ef83f32891f8c1023e4a4f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e85b6c4ab130670916ef83f32891f8c1023e4a4f

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Thu May 21 18:16:15 2020 -0400

pan/mdg: Eliminate remaining divisions from compiler

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5154>

---

 src/panfrost/midgard/midgard_schedule.c |  5 +++--
 src/panfrost/midgard/mir.c              | 12 +++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c
index a365cfaf09e..59fa830f68b 100644
--- a/src/panfrost/midgard/midgard_schedule.c
+++ b/src/panfrost/midgard/midgard_schedule.c
@@ -355,7 +355,8 @@ mir_adjust_constant(midgard_instruction *ins, unsigned src,
                 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),
@@ -413,7 +414,7 @@ mir_adjust_constant(midgard_instruction *ins, unsigned src,
 
                 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;
diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c
index ec6c099db67..0bb87c8fe00 100644
--- a/src/panfrost/midgard/mir.c
+++ b/src/panfrost/midgard/mir.c
@@ -151,11 +151,17 @@ mir_nontrivial_outmod(midgard_instruction *ins)
  *          = 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
@@ -184,7 +190,7 @@ mir_round_bytemask_up(uint16_t mask, unsigned bits)
 {
         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);
@@ -229,7 +235,7 @@ mir_upper_override(midgard_instruction *ins, unsigned inst_size)
          * (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);



More information about the mesa-commit mailing list