From 265515fa62664eac006dcff278ed549c75863b79 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Fri, 13 Aug 2021 16:21:08 +0200 Subject: [PATCH] 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 Signed-off-by: Juan A. Suarez Romero Part-of: --- src/broadcom/compiler/vir.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index 11f89fff212..ffde36b2977 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -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) &&