From: Alyssa Rosenzweig Date: Fri, 10 Jan 2020 23:04:39 +0000 (-0500) Subject: pan/midgard: Bytemasks should round up, not round down X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13c32e5fede9c3ff50d9c6da888914a713654c76;p=mesa.git pan/midgard: Bytemasks should round up, not round down Otherwise we'll lost components in DCE. Signed-off-by: Alyssa Rosenzweig Part-of: --- 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;