lima/ppir: do not assume single src for pipeline outputs

Even if a node has pipeline output and a single successor, it is still
valid for that successor to have multiple references to that pipeline
node. A trivial example is add(u.x,u.y) where u is a uniform.
It is even possible for this to occur with consts as operands of fcsel.
So remove uses of ppir_node_get_src_for_pred as that would assume a
single src in the node that uses the pipeline.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4535>
This commit is contained in:
Erico Nunes 2020-04-13 15:24:35 +02:00 committed by Marge Bot
parent 741aa3439d
commit c6a3987f32
3 changed files with 31 additions and 23 deletions

View file

@ -37,17 +37,24 @@ static bool ppir_lower_const(ppir_block *block, ppir_node *node)
assert(ppir_node_has_single_succ(node));
ppir_node *succ = ppir_node_first_succ(node);
ppir_src *src = ppir_node_get_src_for_pred(succ, node);
ppir_dest *dest = ppir_node_get_dest(node);
assert(src != NULL);
switch (succ->type) {
case ppir_node_type_alu:
case ppir_node_type_branch:
/* ALU and branch can consume consts directly */
dest->type = src->type = ppir_target_pipeline;
dest->type = ppir_target_pipeline;
/* Reg will be updated in node_to_instr later */
dest->pipeline = src->pipeline = ppir_pipeline_reg_const0;
dest->pipeline = ppir_pipeline_reg_const0;
/* single succ can still have multiple references to this node */
for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
ppir_src *src = ppir_node_get_src(succ, i);
if (src && src->node == node) {
src->type = ppir_target_pipeline;
src->pipeline = ppir_pipeline_reg_const0;
}
}
return true;
default:
/* Create a move for everyone else */
@ -105,10 +112,15 @@ static bool ppir_lower_load(ppir_block *block, ppir_node *node)
switch (succ->type) {
case ppir_node_type_alu:
case ppir_node_type_branch: {
ppir_src *src = ppir_node_get_src_for_pred(succ, node);
/* Can consume uniforms directly */
src->type = dest->type = ppir_target_pipeline;
src->pipeline = dest->pipeline = ppir_pipeline_reg_uniform;
/* single succ can still have multiple references to this node */
for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
ppir_src *src = ppir_node_get_src(succ, i);
if (src && src->node == node) {
/* Can consume uniforms directly */
src->type = dest->type = ppir_target_pipeline;
src->pipeline = dest->pipeline = ppir_pipeline_reg_uniform;
}
}
return true;
}
default:

View file

@ -123,10 +123,17 @@ static bool ppir_do_one_node_to_instr(ppir_block *block, ppir_node *node, ppir_n
/* Turn dest back to SSA, so we can update predecessors */
ppir_node *succ = ppir_node_first_succ(node);
ppir_src *succ_src = ppir_node_get_src_for_pred(succ, node);
dest->type = ppir_target_ssa;
dest->ssa.index = -1;
ppir_node_target_assign(succ_src, node);
/* Single succ can still have multiple references to this node */
for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
ppir_src *src = ppir_node_get_src(succ, i);
if (src && src->node == node) {
/* Can consume uniforms directly */
dest->type = ppir_target_ssa;
dest->ssa.index = -1;
ppir_node_target_assign(src, node);
}
}
ppir_node *move = ppir_node_insert_mov(node);
if (unlikely(!move))

View file

@ -550,17 +550,6 @@ static inline ppir_reg *ppir_dest_get_reg(ppir_dest *dest)
}
}
static inline ppir_src *ppir_node_get_src_for_pred(ppir_node *node, ppir_node *pred)
{
for (int i = 0; i < ppir_node_get_src_num(node); i++) {
ppir_src *src = ppir_node_get_src(node, i);
if (src && src->node == pred)
return src;
}
return NULL;
}
static inline void ppir_node_target_assign(ppir_src *src, ppir_node *node)
{
ppir_dest *dest = ppir_node_get_dest(node);