broadcom/compiler: check instruction belongs to current block

Check in the ldunif optimization if the current instruction belongs to
current block.

These avoids again searching the instruction when current block is not
correctly set, as it happened in
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12339 and in
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12221.

v2:
 - Remove extra blank line (Iago)

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12358>
This commit is contained in:
Juan A. Suarez Romero
2021-08-13 16:21:08 +02:00
committed by Marge Bot
parent 3ef2ca9cbf
commit 265515fa62

View File

@@ -1869,6 +1869,21 @@ try_opt_ldunif(struct v3d_compile *c, uint32_t index, struct qreg *unif)
{
uint32_t count = 20;
struct qinst *prev_inst = NULL;
assert(c->cur_block);
#ifdef DEBUG
/* Check if the current instruction is part of the current block */
bool found = false;
vir_for_each_inst(inst, c->cur_block) {
if (&inst->link == c->cursor.link) {
found = true;
break;
}
}
assert(found || list_is_empty(&c->cur_block->instructions));
#endif
list_for_each_entry_from_rev(struct qinst, inst, c->cursor.link->prev,
&c->cur_block->instructions, link) {
if ((inst->qpu.sig.ldunif || inst->qpu.sig.ldunifrf) &&