brw: Track num_instructions in a block

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34012>
This commit is contained in:
Caio Oliveira 2025-03-07 22:08:32 -08:00 committed by Marge Bot
parent abe8d35cb8
commit 1139ede508
3 changed files with 13 additions and 2 deletions

View file

@ -62,7 +62,8 @@ push_stack(exec_list *list, void *mem_ctx, bblock_t *block)
}
bblock_t::bblock_t(cfg_t *cfg) :
cfg(cfg), start_ip(0), end_ip(0), end_ip_delta(0), num(0)
cfg(cfg), start_ip(0), end_ip(0), end_ip_delta(0),
num_instructions(0), num(0)
{
instructions.make_empty();
parents.make_empty();
@ -83,6 +84,7 @@ append_inst(bblock_t *block, brw_inst *inst)
assert(inst->block == NULL);
inst->block = block;
block->instructions.push_tail(inst);
block->num_instructions++;
}
cfg_t::cfg_t(brw_shader *s, exec_list *instructions) :
@ -571,9 +573,12 @@ cfg_t::validate(const char *stage_abbrev)
cfgv_assert(!block->instructions.is_empty());
unsigned num_instructions = 0;
foreach_inst_in_block(brw_inst, inst, block) {
cfgv_assert(block == inst->block);
num_instructions++;
}
cfgv_assert(num_instructions == block->num_instructions);
brw_inst *first_inst = block->start();
if (first_inst->opcode == BRW_OPCODE_DO) {

View file

@ -105,6 +105,8 @@ struct bblock_t {
*/
int end_ip_delta;
unsigned num_instructions;
struct exec_list instructions;
struct exec_list parents;
struct exec_list children;

View file

@ -982,6 +982,7 @@ brw_inst::insert_before(bblock_t *block, brw_inst *inst)
exec_node::insert_before(inst);
inst->block = block;
inst->block->num_instructions++;
}
void
@ -997,6 +998,9 @@ brw_inst::remove(bool defer_later_block_ip_updates)
return;
}
assert(block->num_instructions > 0);
block->num_instructions--;
if (defer_later_block_ip_updates) {
block->end_ip_delta--;
} else {
@ -1004,7 +1008,7 @@ brw_inst::remove(bool defer_later_block_ip_updates)
adjust_later_block_ips(block, -1);
}
if (block->start_ip == block->end_ip) {
if (block->num_instructions == 0) {
if (block->end_ip_delta != 0) {
adjust_later_block_ips(block, block->end_ip_delta);
block->end_ip_delta = 0;