mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 20:00:10 +01:00
brw: Remove adjust_block_ips and brw_inst::remove() with defer
Now that the brw_ip_ranges analysis is being used, there's no need to track start_ip/end_ips in the blocks as they are mutate. And also no need to call adjust_block_ips at the end of some passes. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34012>
This commit is contained in:
parent
8057cfc49d
commit
63224f64cc
10 changed files with 17 additions and 99 deletions
|
|
@ -62,8 +62,7 @@ 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_instructions(0), num(0)
|
||||
cfg(cfg), num_instructions(0), num(0)
|
||||
{
|
||||
instructions.make_empty();
|
||||
parents.make_empty();
|
||||
|
|
@ -332,8 +331,6 @@ cfg_t::cfg_t(brw_shader *s, exec_list *instructions) :
|
|||
}
|
||||
}
|
||||
|
||||
cur->end_ip = ip - 1;
|
||||
|
||||
make_block_array();
|
||||
}
|
||||
|
||||
|
|
@ -462,11 +459,6 @@ cfg_t::new_block()
|
|||
void
|
||||
cfg_t::set_next_block(bblock_t **cur, bblock_t *block, int ip)
|
||||
{
|
||||
if (*cur) {
|
||||
(*cur)->end_ip = ip - 1;
|
||||
}
|
||||
|
||||
block->start_ip = ip;
|
||||
block->num = num_blocks++;
|
||||
block_list.push_tail(&block->link);
|
||||
*cur = block;
|
||||
|
|
|
|||
|
|
@ -97,14 +97,6 @@ struct bblock_t {
|
|||
struct exec_node link;
|
||||
struct cfg_t *cfg;
|
||||
|
||||
int start_ip;
|
||||
int end_ip;
|
||||
|
||||
/**
|
||||
* Change in end_ip since the last time IPs of later blocks were updated.
|
||||
*/
|
||||
int end_ip_delta;
|
||||
|
||||
unsigned num_instructions;
|
||||
|
||||
struct exec_list instructions;
|
||||
|
|
@ -219,11 +211,6 @@ struct cfg_t {
|
|||
void validate(const char *stage_abbrev);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Propagate bblock_t::end_ip_delta data through the CFG.
|
||||
*/
|
||||
inline void adjust_block_ips();
|
||||
|
||||
struct brw_shader *s;
|
||||
void *mem_ctx;
|
||||
|
||||
|
|
@ -311,19 +298,4 @@ cfg_t::last_block() const
|
|||
!__scan_inst->is_head_sentinel(); \
|
||||
__scan_inst = (__type *)__scan_inst->prev)
|
||||
|
||||
inline void
|
||||
cfg_t::adjust_block_ips()
|
||||
{
|
||||
int delta = 0;
|
||||
|
||||
foreach_block(block, this) {
|
||||
block->start_ip += delta;
|
||||
block->end_ip += delta;
|
||||
|
||||
delta += block->end_ip_delta;
|
||||
|
||||
block->end_ip_delta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -956,29 +956,13 @@ brw_inst::is_volatile() const
|
|||
opcode == SHADER_OPCODE_SEND_GATHER) && send_is_volatile);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_later_block_ips(bblock_t *start_block, int ip_adjustment)
|
||||
{
|
||||
for (bblock_t *block_iter = start_block->next();
|
||||
block_iter;
|
||||
block_iter = block_iter->next()) {
|
||||
block_iter->start_ip += ip_adjustment;
|
||||
block_iter->end_ip += ip_adjustment;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
brw_inst::insert_before(bblock_t *block, brw_inst *inst)
|
||||
{
|
||||
assert(this != inst);
|
||||
assert(block->end_ip_delta == 0);
|
||||
|
||||
assert(!inst->block || inst->block == block);
|
||||
|
||||
block->end_ip++;
|
||||
|
||||
adjust_later_block_ips(block, 1);
|
||||
|
||||
exec_node::insert_before(inst);
|
||||
|
||||
inst->block = block;
|
||||
|
|
@ -987,7 +971,7 @@ brw_inst::insert_before(bblock_t *block, brw_inst *inst)
|
|||
}
|
||||
|
||||
void
|
||||
brw_inst::remove(bool defer_later_block_ip_updates)
|
||||
brw_inst::remove()
|
||||
{
|
||||
assert(block);
|
||||
|
||||
|
|
@ -1004,23 +988,8 @@ brw_inst::remove(bool defer_later_block_ip_updates)
|
|||
block->num_instructions--;
|
||||
block->cfg->total_instructions--;
|
||||
|
||||
if (defer_later_block_ip_updates) {
|
||||
block->end_ip_delta--;
|
||||
} else {
|
||||
assert(block->end_ip_delta == 0);
|
||||
adjust_later_block_ips(block, -1);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (block->num_instructions == 0)
|
||||
block->cfg->remove_block(block);
|
||||
} else {
|
||||
block->end_ip--;
|
||||
}
|
||||
|
||||
exec_node::remove();
|
||||
block = NULL;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public:
|
|||
*/
|
||||
bool uses_indirect_addressing() const;
|
||||
|
||||
void remove(bool defer_later_block_ip_updates = false);
|
||||
void remove();
|
||||
void insert_before(bblock_t *block, brw_inst *inst);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ brw_opt_address_reg_load(brw_shader &s)
|
|||
}
|
||||
|
||||
if (progress) {
|
||||
s.cfg->adjust_block_ips();
|
||||
s.invalidate_analysis(BRW_DEPENDENCY_INSTRUCTIONS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ cmod_propagate_cmp_to_add(const intel_device_info *devinfo, brw_inst *inst)
|
|||
scan_inst->conditional_mod == cond)) {
|
||||
scan_inst->conditional_mod = cond;
|
||||
scan_inst->flag_subreg = inst->flag_subreg;
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -203,7 +203,7 @@ cmod_propagate_not(const intel_device_info *devinfo, brw_inst *inst)
|
|||
scan_inst->conditional_mod == cond)) {
|
||||
scan_inst->conditional_mod = cond;
|
||||
scan_inst->flag_subreg = inst->flag_subreg;
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -223,11 +223,8 @@ static bool
|
|||
opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
|
||||
{
|
||||
bool progress = false;
|
||||
UNUSED int ip = block->end_ip + 1;
|
||||
|
||||
foreach_inst_in_block_reverse_safe(brw_inst, inst, block) {
|
||||
ip--;
|
||||
|
||||
if ((inst->opcode != BRW_OPCODE_AND &&
|
||||
inst->opcode != BRW_OPCODE_CMP &&
|
||||
inst->opcode != BRW_OPCODE_MOV &&
|
||||
|
|
@ -310,7 +307,7 @@ opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
|
|||
if (inst->conditional_mod == BRW_CONDITIONAL_NZ &&
|
||||
scan_inst->opcode == BRW_OPCODE_CMP &&
|
||||
brw_type_is_int(inst->dst.type)) {
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
progress = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -458,20 +455,20 @@ opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
|
|||
inst->src[0].type == BRW_TYPE_UD) ||
|
||||
(inst->conditional_mod == BRW_CONDITIONAL_L &&
|
||||
inst->src[0].type == BRW_TYPE_D)) {
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
progress = true;
|
||||
break;
|
||||
}
|
||||
} else if (scan_inst->conditional_mod == inst->conditional_mod) {
|
||||
/* sel.cond will not write the flags. */
|
||||
assert(scan_inst->opcode != BRW_OPCODE_SEL);
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
progress = true;
|
||||
break;
|
||||
} else if (!read_flag && scan_inst->can_do_cmod()) {
|
||||
scan_inst->conditional_mod = inst->conditional_mod;
|
||||
scan_inst->flag_subreg = inst->flag_subreg;
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
progress = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -533,7 +530,7 @@ opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
|
|||
scan_inst->conditional_mod == cond)) {
|
||||
scan_inst->conditional_mod = cond;
|
||||
scan_inst->flag_subreg = inst->flag_subreg;
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
progress = true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -547,9 +544,6 @@ opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
|
|||
}
|
||||
}
|
||||
|
||||
/* There is progress if and only if instructions were removed. */
|
||||
assert(progress == (block->end_ip_delta != 0));
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
|
|
@ -563,8 +557,6 @@ brw_opt_cmod_propagation(brw_shader &s)
|
|||
}
|
||||
|
||||
if (progress) {
|
||||
s.cfg->adjust_block_ips();
|
||||
|
||||
s.invalidate_analysis(BRW_DEPENDENCY_INSTRUCTIONS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1883,7 +1883,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(true);
|
||||
def->remove();
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
@ -1917,7 +1917,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(true);
|
||||
def->remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1929,7 +1929,6 @@ brw_opt_copy_propagation_defs(brw_shader &s)
|
|||
}
|
||||
|
||||
if (progress) {
|
||||
s.cfg->adjust_block_ips();
|
||||
s.invalidate_analysis(BRW_DEPENDENCY_INSTRUCTIONS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ brw_opt_cse_defs(brw_shader &s)
|
|||
* which is redundant with the previous flag write in our
|
||||
* basic block. So we can simply remove it.
|
||||
*/
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
last = NULL;
|
||||
progress = true;
|
||||
}
|
||||
|
|
@ -497,7 +497,7 @@ brw_opt_cse_defs(brw_shader &s)
|
|||
continue;
|
||||
|
||||
if (!remap_table[i].still_used) {
|
||||
remap_table[i].inst->remove(true);
|
||||
remap_table[i].inst->remove();
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -507,7 +507,6 @@ out:
|
|||
_mesa_set_destroy(set, NULL);
|
||||
|
||||
if (progress) {
|
||||
s.cfg->adjust_block_ips();
|
||||
s.invalidate_analysis(BRW_DEPENDENCY_INSTRUCTIONS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ brw_opt_dead_code_eliminate(brw_shader &s)
|
|||
flag_live[0] &= ~inst->flags_written(devinfo);
|
||||
|
||||
if (inst->opcode == BRW_OPCODE_NOP) {
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -169,8 +169,6 @@ brw_opt_dead_code_eliminate(brw_shader &s)
|
|||
}
|
||||
}
|
||||
|
||||
s.cfg->adjust_block_ips();
|
||||
|
||||
ralloc_free(live);
|
||||
ralloc_free(flag_live);
|
||||
|
||||
|
|
|
|||
|
|
@ -372,12 +372,10 @@ brw_opt_register_coalesce(brw_shader &s)
|
|||
if (progress) {
|
||||
foreach_block_and_inst_safe (block, brw_inst, inst, s.cfg) {
|
||||
if (inst->opcode == BRW_OPCODE_NOP) {
|
||||
inst->remove(true);
|
||||
inst->remove();
|
||||
}
|
||||
}
|
||||
|
||||
s.cfg->adjust_block_ips();
|
||||
|
||||
s.invalidate_analysis(BRW_DEPENDENCY_INSTRUCTIONS);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue