brw: Use brw_inst::block in Def analysis
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33815>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user