From 07d0af763d4d8096822822eaa107c19cb0f61cc6 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Thu, 27 Feb 2025 09:28:48 -0800 Subject: [PATCH] brw: Use brw_inst::block in Def analysis Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_analysis.h | 12 ++---------- src/intel/compiler/brw_analysis_def.cpp | 17 +++-------------- src/intel/compiler/brw_opt_copy_propagation.cpp | 4 ++-- src/intel/compiler/brw_opt_cse.cpp | 2 +- .../compiler/brw_opt_saturate_propagation.cpp | 2 +- 5 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/intel/compiler/brw_analysis.h b/src/intel/compiler/brw_analysis.h index 45602dc8155..8200858c03b 100644 --- a/src/intel/compiler/brw_analysis.h +++ b/src/intel/compiler/brw_analysis.h @@ -270,13 +270,6 @@ public: def_insts[reg.nr] : NULL; } - bblock_t * - get_block(const brw_reg ®) const - { - return reg.file == VGRF && reg.nr < def_count ? - def_blocks[reg.nr] : NULL; - } - uint32_t get_use_count(const brw_reg ®) const { @@ -303,11 +296,10 @@ public: private: void mark_invalid(int); bool fully_defines(const brw_shader *v, brw_inst *); - void update_for_reads(const brw_idom_tree &idom, bblock_t *block, brw_inst *); - void update_for_write(const brw_shader *v, bblock_t *block, brw_inst *); + void update_for_reads(const brw_idom_tree &idom, brw_inst *); + void update_for_write(const brw_shader *v, brw_inst *); brw_inst **def_insts; - bblock_t **def_blocks; uint32_t *def_use_counts; unsigned def_count; }; diff --git a/src/intel/compiler/brw_analysis_def.cpp b/src/intel/compiler/brw_analysis_def.cpp index 189773dec94..1a3828932b5 100644 --- a/src/intel/compiler/brw_analysis_def.cpp +++ b/src/intel/compiler/brw_analysis_def.cpp @@ -30,7 +30,6 @@ * * const def_analysis &defs = s.def_analysis.require(); * brw_inst *def = defs.get(inst->src[i]); // returns NULL if non-SSA - * bblock_t *block = defs.get_block(inst->src[i]); // block containing def * * Def analysis requires the dominator tree, but not liveness information. */ @@ -40,13 +39,11 @@ static brw_inst *const UNSEEN = (brw_inst *) (uintptr_t) 1; void brw_def_analysis::mark_invalid(int nr) { - def_blocks[nr] = NULL; def_insts[nr] = NULL; } void brw_def_analysis::update_for_reads(const brw_idom_tree &idom, - bblock_t *block, brw_inst *inst) { /* We don't track accumulator use for def analysis, so if an instruction @@ -81,7 +78,7 @@ brw_def_analysis::update_for_reads(const brw_idom_tree &idom, * */ if (def_insts[nr] == UNSEEN || - !idom.dominates(def_blocks[nr], block)) + !idom.dominates(def_insts[nr]->block, inst->block)) mark_invalid(nr); } @@ -102,7 +99,6 @@ brw_def_analysis::fully_defines(const brw_shader *v, brw_inst *inst) void brw_def_analysis::update_for_write(const brw_shader *v, - bblock_t *block, brw_inst *inst) { const int nr = inst->dst.nr; @@ -115,7 +111,6 @@ brw_def_analysis::update_for_write(const brw_shader *v, */ if (def_insts[nr] == UNSEEN && fully_defines(v, inst)) { def_insts[nr] = inst; - def_blocks[nr] = block; } else { /* Otherwise this is a second write or a partial write, in which * case we know with certainty that this isn't an SSA def. @@ -131,7 +126,6 @@ brw_def_analysis::brw_def_analysis(const brw_shader *v) def_count = v->alloc.count; def_insts = new brw_inst*[def_count](); - def_blocks = new bblock_t*[def_count](); def_use_counts = new uint32_t[def_count](); for (unsigned i = 0; i < def_count; i++) @@ -139,8 +133,8 @@ brw_def_analysis::brw_def_analysis(const brw_shader *v) foreach_block_and_inst(block, brw_inst, inst, v->cfg) { if (inst->opcode != SHADER_OPCODE_UNDEF) { - update_for_reads(idom, block, inst); - update_for_write(v, block, inst); + update_for_reads(idom, inst); + update_for_write(v, inst); } } @@ -177,17 +171,12 @@ brw_def_analysis::brw_def_analysis(const brw_shader *v) brw_def_analysis::~brw_def_analysis() { delete[] def_insts; - delete[] def_blocks; delete[] def_use_counts; } bool brw_def_analysis::validate(const brw_shader *v) const { - for (unsigned i = 0; i < def_count; i++) { - assert(!def_insts[i] == !def_blocks[i]); - } - return true; } diff --git a/src/intel/compiler/brw_opt_copy_propagation.cpp b/src/intel/compiler/brw_opt_copy_propagation.cpp index e3df122db1a..596fb08709c 100644 --- a/src/intel/compiler/brw_opt_copy_propagation.cpp +++ b/src/intel/compiler/brw_opt_copy_propagation.cpp @@ -1879,7 +1879,7 @@ brw_opt_copy_propagation_defs(brw_shader &s) progress = true; ++uses_deleted[def->dst.nr]; if (defs.get_use_count(def->dst) == uses_deleted[def->dst.nr]) - def->remove(defs.get_block(def->dst), true); + def->remove(def->block, true); } continue; @@ -1913,7 +1913,7 @@ brw_opt_copy_propagation_defs(brw_shader &s) */ if (def->conditional_mod == BRW_CONDITIONAL_NONE && defs.get_use_count(def->dst) == uses_deleted[def->dst.nr]) { - def->remove(defs.get_block(def->dst), true); + def->remove(def->block, true); } } } diff --git a/src/intel/compiler/brw_opt_cse.cpp b/src/intel/compiler/brw_opt_cse.cpp index 99afffe823d..2e1cd95029d 100644 --- a/src/intel/compiler/brw_opt_cse.cpp +++ b/src/intel/compiler/brw_opt_cse.cpp @@ -450,7 +450,7 @@ brw_opt_cse_defs(brw_shader &s) if (match == inst) continue; - bblock_t *def_block = defs.get_block(match->dst); + bblock_t *def_block = match->block; if (block != def_block && (local_only(inst) || !idom.dominates(def_block, block))) { /* If `match` doesn't dominate `inst` then remove it from diff --git a/src/intel/compiler/brw_opt_saturate_propagation.cpp b/src/intel/compiler/brw_opt_saturate_propagation.cpp index e3c792eebfc..0ad9a031535 100644 --- a/src/intel/compiler/brw_opt_saturate_propagation.cpp +++ b/src/intel/compiler/brw_opt_saturate_propagation.cpp @@ -129,7 +129,7 @@ opt_saturate_propagation_local(brw_shader &s, bblock_t *block) /* If the def is in a different block the liveness based pass will * not be able to make progress, so skip it. */ - if (block != defs.get_block(inst->src[0])) + if (block != def->block) continue; }