pan/midgard: Bytemasks should round up, not round down

Otherwise we'll lost components in DCE.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3462>
This commit is contained in:
Alyssa Rosenzweig 2020-01-10 18:04:39 -05:00 committed by Marge Bot
parent 5e8386c606
commit 13c32e5fed
3 changed files with 8 additions and 9 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;