pan/mdg: Eliminate expand_writemask division
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 21 May 2020 22:04:36 +0000 (18:04 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 21 May 2020 22:29:53 +0000 (18:29 -0400)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5154>

src/panfrost/midgard/helpers.h
src/panfrost/midgard/midgard_emit.c

index 658c43b785d17883034e0bd55005f47dcbf3fb6f..a7177ce2f2e80783038175a6e71e7be50dd8fa87 100644 (file)
@@ -240,13 +240,13 @@ struct mir_tag_props {
  * which is used for vector units */
 
 static inline unsigned
-expand_writemask(unsigned mask, unsigned channels)
+expand_writemask(unsigned mask, unsigned log2_channels)
 {
         unsigned o = 0;
-        unsigned factor = 8 channels;
+        unsigned factor = 8 >> log2_channels;
         unsigned expanded = (1 << factor) - 1;
 
-        for (unsigned i = 0; i < channels; ++i)
+        for (unsigned i = 0; i < (1 << log2_channels); ++i)
                 if (mask & (1 << i))
                         o |= (expanded << (factor * i));
 
index c8340f9e44d06dce75a4bc6365b977559386cf78..6431dc02c0e0f6eefd66c2323b25bc04c37a08a9 100644 (file)
@@ -184,9 +184,9 @@ mir_pack_mask_alu(midgard_instruction *ins)
         }
 
         if (ins->alu.reg_mode == midgard_reg_mode_32)
-                ins->alu.mask = expand_writemask(effective, 4);
-        else if (ins->alu.reg_mode == midgard_reg_mode_64)
                 ins->alu.mask = expand_writemask(effective, 2);
+        else if (ins->alu.reg_mode == midgard_reg_mode_64)
+                ins->alu.mask = expand_writemask(effective, 1);
         else
                 ins->alu.mask = effective;
 }