aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-01-10 18:04:39 -0500
committerMarge Bot <[email protected]>2020-01-18 14:18:48 +0000
commit13c32e5fede9c3ff50d9c6da888914a713654c76 (patch)
tree9f3ea66595c692734141be668e5d07ed404de7d5
parent5e8386c606293de4f9cbbc2666a9e9e3758b6b29 (diff)
pan/midgard: Bytemasks should round up, not round down
Otherwise we'll lost components in DCE. Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3462>
-rw-r--r--src/panfrost/midgard/compiler.h2
-rw-r--r--src/panfrost/midgard/midgard_opt_dce.c2
-rw-r--r--src/panfrost/midgard/mir.c13
3 files changed, 8 insertions, 9 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index 172b6d70f69..ab9cc819ef6 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -537,7 +537,7 @@ midgard_reg_mode mir_mode_for_destsize(unsigned size);
uint16_t mir_from_bytemask(uint16_t bytemask, midgard_reg_mode mode);
uint16_t mir_to_bytemask(midgard_reg_mode mode, unsigned mask);
uint16_t mir_bytemask(midgard_instruction *ins);
-uint16_t mir_round_bytemask_down(uint16_t mask, midgard_reg_mode mode);
+uint16_t mir_round_bytemask_up(uint16_t mask, midgard_reg_mode mode);
void mir_set_bytemask(midgard_instruction *ins, uint16_t bytemask);
unsigned mir_upper_override(midgard_instruction *ins);
diff --git a/src/panfrost/midgard/midgard_opt_dce.c b/src/panfrost/midgard/midgard_opt_dce.c
index aaac84fe16e..0b2823be782 100644
--- a/src/panfrost/midgard/midgard_opt_dce.c
+++ b/src/panfrost/midgard/midgard_opt_dce.c
@@ -74,7 +74,7 @@ midgard_opt_dead_code_eliminate(compiler_context *ctx, midgard_block *block)
midgard_reg_mode mode = mir_typesize(ins);
unsigned oldmask = ins->mask;
- unsigned rounded = mir_round_bytemask_down(live[ins->dest], mode);
+ unsigned rounded = mir_round_bytemask_up(live[ins->dest], mode);
unsigned cmask = mir_from_bytemask(rounded, mode);
ins->mask &= cmask;
diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c
index 506bcabe656..d4ce935934c 100644
--- a/src/panfrost/midgard/mir.c
+++ b/src/panfrost/midgard/mir.c
@@ -381,22 +381,21 @@ mir_from_bytemask(uint16_t bytemask, midgard_reg_mode mode)
return value;
}
-/* Rounds down a bytemask to fit a given component count. Iterate each
- * component, and check if all bytes in the component are masked on */
+/* Rounds up a bytemask to fill a given component count. Iterate each
+ * component, and check if any bytes in the component are masked on */
uint16_t
-mir_round_bytemask_down(uint16_t mask, midgard_reg_mode mode)
+mir_round_bytemask_up(uint16_t mask, midgard_reg_mode mode)
{
unsigned bytes = mir_bytes_for_mode(mode);
unsigned maxmask = mask_of(bytes);
unsigned channels = 16 / bytes;
for (unsigned c = 0; c < channels; ++c) {
- /* Get bytes in component */
- unsigned submask = (mask >> (c * bytes)) & maxmask;
+ unsigned submask = maxmask << (c * bytes);
- if (submask != maxmask)
- mask &= ~(maxmask << (c * bytes));
+ if (mask & submask)
+ mask |= submask;
}
return mask;