From 28a750c5f2a4b31c4d58165d19c91310b05a26b1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 21 May 2020 18:04:36 -0400 Subject: [PATCH] pan/mdg: Eliminate expand_writemask division Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/helpers.h | 6 +++--- src/panfrost/midgard/midgard_emit.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/panfrost/midgard/helpers.h b/src/panfrost/midgard/helpers.h index 658c43b785d..a7177ce2f2e 100644 --- a/src/panfrost/midgard/helpers.h +++ b/src/panfrost/midgard/helpers.h @@ -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)); diff --git a/src/panfrost/midgard/midgard_emit.c b/src/panfrost/midgard/midgard_emit.c index c8340f9e44d..6431dc02c0e 100644 --- a/src/panfrost/midgard/midgard_emit.c +++ b/src/panfrost/midgard/midgard_emit.c @@ -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; } -- 2.30.2