lima: ppir: try inserting nodes into successor instr for uncond branch

It is safe to attempt inserting a node into the same instruction as
successor if successor is an unconditional branch.
ppir_instr_insert_node() will take care of conflicts with ALU_COMBINE
slot

Reviewed-by: Erico Nunes <nunes.erico@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33754>
This commit is contained in:
Vasily Khoruzhick 2025-02-25 23:14:23 -08:00 committed by Marge Bot
parent fa9ddbe82b
commit dd765da872
2 changed files with 18 additions and 0 deletions

View file

@ -238,6 +238,13 @@ bool ppir_instr_insert_node(ppir_instr *instr, ppir_node *node)
}
}
if (pos == PPIR_INSTR_SLOT_BRANCH) {
/* Branch and combiner run in parallel, they cannot be inserted
* into the same instruction */
if (instr->slots[PPIR_INSTR_SLOT_ALU_COMBINE])
return false;
}
if (pos == PPIR_INSTR_SLOT_ALU_VEC_MUL) {
if (dest && dest->type == ppir_target_pipeline) {
ppir_node *add = ppir_node_first_succ(node);

View file

@ -121,6 +121,17 @@ static bool ppir_do_one_node_to_instr(ppir_block *block, ppir_node *node)
}
if (!node->instr &&
ppir_node_has_single_succ(node)) {
ppir_node *succ = ppir_node_first_succ(node);
if (succ->op == ppir_op_branch &&
ppir_node_get_src_num(succ) == 0 &&
succ->instr) {
/* Unconditional branch. Likely a loop */
ppir_instr_insert_node(succ->instr, node);
}
}
/* can't inserted to any existing instr, create one */
if (!node->instr && !create_new_instr(block, node))
return false;