intel/brw: Track the number of uses of each def in def_analysis

Even without a full use list, simply tracking the number of uses will
let us tell "this is the only use of the def" or "we've just replaced
all uses of a def".  It's inexpensive to calculate and will be useful.

(rebased by Kenneth Graunke)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28666>
This commit is contained in:
Caio Oliveira 2024-01-12 11:49:11 -08:00 committed by Marge Bot
parent 0d144821f0
commit 08da7edc0e
2 changed files with 14 additions and 2 deletions

View file

@ -73,6 +73,8 @@ def_analysis::update_for_reads(const idom_tree &idom,
continue;
}
def_use_counts[nr]++;
if (def_insts[nr]) {
/* Mark the source def invalid in two cases:
*
@ -130,8 +132,9 @@ def_analysis::def_analysis(const fs_visitor *v)
def_count = v->alloc.count;
def_insts = new fs_inst*[def_count]();
def_blocks = new bblock_t*[def_count]();
def_insts = new fs_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++)
def_insts[i] = UNSEEN;
@ -177,6 +180,7 @@ def_analysis::~def_analysis()
{
delete[] def_insts;
delete[] def_blocks;
delete[] def_use_counts;
}
bool

View file

@ -89,6 +89,13 @@ namespace brw {
def_blocks[reg.nr] : NULL;
}
uint32_t
get_use_count(const fs_reg &reg) const
{
return reg.file == VGRF && reg.nr < def_count ?
def_use_counts[reg.nr] : 0;
}
unsigned count() const { return def_count; }
void print_stats(const fs_visitor *) const;
@ -112,6 +119,7 @@ namespace brw {
fs_inst **def_insts;
bblock_t **def_blocks;
uint32_t *def_use_counts;
unsigned def_count;
};
}