diff options
author | Erico Nunes <[email protected]> | 2020-01-20 01:29:40 +0100 |
---|---|---|
committer | Erico Nunes <[email protected]> | 2020-01-25 14:48:55 +0100 |
commit | ae0b8ba5d568f0029f868e02e388c7a71474f6eb (patch) | |
tree | 7e8769e080145e4bf75eb29f5ce4311e4f7a3786 /src/gallium/drivers/lima/ir | |
parent | ab36523ae7c4abe3fa55c43e9c5e63b157aa7981 (diff) |
lima/ppir: fix src read mask swizzling
The src mask can't be calculated from the dest write_mask.
Instead, it must be calculated from the swizzled operators of the src.
Otherwise, liveness calculation may report incorrect live components for
non-ssa registers.
Signed-off-by: Erico Nunes <[email protected]>
Reviewed-by: Vasily Khoruzhick <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3502>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3502>
Diffstat (limited to 'src/gallium/drivers/lima/ir')
-rw-r--r-- | src/gallium/drivers/lima/ir/pp/liveness.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/lima/ir/pp/ppir.h | 20 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/gallium/drivers/lima/ir/pp/liveness.c b/src/gallium/drivers/lima/ir/pp/liveness.c index 1bc1dc812c6..ccc01a3545f 100644 --- a/src/gallium/drivers/lima/ir/pp/liveness.c +++ b/src/gallium/drivers/lima/ir/pp/liveness.c @@ -148,7 +148,7 @@ ppir_liveness_instr_srcs(ppir_compiler *comp, ppir_instr *instr) _mesa_set_add(instr->live_in_set, &instr->live_in[reg->regalloc_index]); } else { - unsigned int mask = ppir_src_get_mask(node); + unsigned int mask = ppir_src_get_mask(src); /* read reg is type register, need to check if this sets * any additional bits in the current mask */ @@ -209,7 +209,7 @@ ppir_liveness_instr_dest(ppir_compiler *comp, ppir_instr *instr) _mesa_set_remove_key(instr->live_in_set, &instr->live_in[reg->regalloc_index]); } else { - unsigned int mask = ppir_src_get_mask(node); + unsigned int mask = dest->write_mask; /* written reg is type register, need to check if this clears * the remaining mask to remove it from the live set */ if (instr->live_in[reg->regalloc_index].mask == diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h index b2637cb68c3..2b4629bcaab 100644 --- a/src/gallium/drivers/lima/ir/pp/ppir.h +++ b/src/gallium/drivers/lima/ir/pp/ppir.h @@ -478,15 +478,6 @@ static inline ppir_dest *ppir_node_get_dest(ppir_node *node) } } -static inline int ppir_src_get_mask(ppir_node *node) -{ - ppir_dest *dest = ppir_node_get_dest(node); - if (dest) - return dest->write_mask; - - return 0x01; -} - static inline int ppir_node_get_src_num(ppir_node *node) { switch (node->type) { @@ -635,6 +626,17 @@ static inline int ppir_target_get_dest_reg_index(ppir_dest *dest) return -1; } +static inline int ppir_src_get_mask(ppir_src *src) +{ + ppir_reg *reg = ppir_src_get_reg(src); + int mask = 0; + + for (int i = 0; i < reg->num_components; i++) + mask |= (1 << src->swizzle[i]); + + return mask; +} + static inline bool ppir_target_is_scaler(ppir_dest *dest) { switch (dest->type) { |