intel/fs: Use linear allocator in opt_copy_propagation

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25670>
This commit is contained in:
Caio Oliveira 2023-10-02 10:39:09 -07:00 committed by Marge Bot
parent 6d2503e935
commit b5cd91501d

View file

@ -265,7 +265,7 @@ struct block_data {
class fs_copy_prop_dataflow
{
public:
fs_copy_prop_dataflow(void *mem_ctx, cfg_t *cfg,
fs_copy_prop_dataflow(linear_ctx *lin_ctx, cfg_t *cfg,
const fs_live_variables &live,
struct acp *out_acp);
@ -274,7 +274,6 @@ public:
void dump_block_data() const UNUSED;
void *mem_ctx;
cfg_t *cfg;
const fs_live_variables &live;
@ -286,31 +285,33 @@ public:
};
} /* anonymous namespace */
fs_copy_prop_dataflow::fs_copy_prop_dataflow(void *mem_ctx, cfg_t *cfg,
fs_copy_prop_dataflow::fs_copy_prop_dataflow(linear_ctx *lin_ctx, cfg_t *cfg,
const fs_live_variables &live,
struct acp *out_acp)
: mem_ctx(mem_ctx), cfg(cfg), live(live)
: cfg(cfg), live(live)
{
bd = rzalloc_array(mem_ctx, struct block_data, cfg->num_blocks);
bd = linear_zalloc_array(lin_ctx, struct block_data, cfg->num_blocks);
num_acp = 0;
foreach_block (block, cfg)
num_acp += out_acp[block->num].length();
acp = rzalloc_array(mem_ctx, struct acp_entry *, num_acp);
bitset_words = BITSET_WORDS(num_acp);
foreach_block (block, cfg) {
bd[block->num].livein = linear_zalloc_array(lin_ctx, BITSET_WORD, bitset_words);
bd[block->num].liveout = linear_zalloc_array(lin_ctx, BITSET_WORD, bitset_words);
bd[block->num].copy = linear_zalloc_array(lin_ctx, BITSET_WORD, bitset_words);
bd[block->num].kill = linear_zalloc_array(lin_ctx, BITSET_WORD, bitset_words);
bd[block->num].undef = linear_zalloc_array(lin_ctx, BITSET_WORD, bitset_words);
bd[block->num].reachin = linear_zalloc_array(lin_ctx, BITSET_WORD, bitset_words);
bd[block->num].exec_mismatch = linear_zalloc_array(lin_ctx, BITSET_WORD, bitset_words);
}
acp = linear_zalloc_array(lin_ctx, struct acp_entry *, num_acp);
int next_acp = 0;
foreach_block (block, cfg) {
bd[block->num].livein = rzalloc_array(bd, BITSET_WORD, bitset_words);
bd[block->num].liveout = rzalloc_array(bd, BITSET_WORD, bitset_words);
bd[block->num].copy = rzalloc_array(bd, BITSET_WORD, bitset_words);
bd[block->num].kill = rzalloc_array(bd, BITSET_WORD, bitset_words);
bd[block->num].undef = rzalloc_array(bd, BITSET_WORD, bitset_words);
bd[block->num].reachin = rzalloc_array(bd, BITSET_WORD, bitset_words);
bd[block->num].exec_mismatch = rzalloc_array(bd, BITSET_WORD, bitset_words);
for (auto iter = out_acp[block->num].begin();
iter != out_acp[block->num].end(); ++iter) {
acp[next_acp] = *iter;
@ -1273,7 +1274,7 @@ can_propagate_from(fs_inst *inst)
* list.
*/
static bool
opt_copy_propagation_local(const brw_compiler *compiler, void *copy_prop_ctx,
opt_copy_propagation_local(const brw_compiler *compiler, linear_ctx *lin_ctx,
bblock_t *block, struct acp &acp,
const brw::simple_allocator &alloc,
uint8_t max_polygons)
@ -1355,7 +1356,7 @@ opt_copy_propagation_local(const brw_compiler *compiler, void *copy_prop_ctx,
* operand of another instruction, add it to the ACP.
*/
if (can_propagate_from(inst)) {
acp_entry *entry = rzalloc(copy_prop_ctx, acp_entry);
acp_entry *entry = linear_zalloc(lin_ctx, acp_entry);
entry->dst = inst->dst;
entry->src = inst->src[0];
entry->size_written = inst->size_written;
@ -1379,7 +1380,7 @@ opt_copy_propagation_local(const brw_compiler *compiler, void *copy_prop_ctx,
BRW_REGISTER_TYPE_UD : inst->src[i].type;
fs_reg dst = byte_offset(retype(inst->dst, t), offset);
if (!dst.equals(inst->src[i])) {
acp_entry *entry = rzalloc(copy_prop_ctx, acp_entry);
acp_entry *entry = linear_zalloc(lin_ctx, acp_entry);
entry->dst = dst;
entry->src = retype(inst->src[i], t);
entry->size_written = size_written;
@ -1402,6 +1403,7 @@ fs_visitor::opt_copy_propagation()
{
bool progress = false;
void *copy_prop_ctx = ralloc_context(NULL);
linear_ctx *lin_ctx = linear_context(copy_prop_ctx);
struct acp out_acp[cfg->num_blocks];
const fs_live_variables &live = live_analysis.require();
@ -1410,7 +1412,7 @@ fs_visitor::opt_copy_propagation()
* the set of copies available at the end of the block.
*/
foreach_block (block, cfg) {
progress = opt_copy_propagation_local(compiler, copy_prop_ctx, block,
progress = opt_copy_propagation_local(compiler, lin_ctx, block,
out_acp[block->num], alloc,
max_polygons) || progress;
@ -1435,7 +1437,7 @@ fs_visitor::opt_copy_propagation()
}
/* Do dataflow analysis for those available copies. */
fs_copy_prop_dataflow dataflow(copy_prop_ctx, cfg, live, out_acp);
fs_copy_prop_dataflow dataflow(lin_ctx, cfg, live, out_acp);
/* Next, re-run local copy propagation, this time with the set of copies
* provided by the dataflow analysis available at the start of a block.
@ -1451,7 +1453,7 @@ fs_visitor::opt_copy_propagation()
}
}
progress = opt_copy_propagation_local(compiler, copy_prop_ctx, block,
progress = opt_copy_propagation_local(compiler, lin_ctx, block,
in_acp, alloc, max_polygons) ||
progress;
}