brw: Perform mark_last_urb_write_with_eot optimization after CFG
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Avoid using exec_node::remove() and the initial "main list of
instructions", and instead use the existing helpers like other
passes.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37146>
This commit is contained in:
Caio Oliveira 2025-04-02 14:01:42 -07:00 committed by Marge Bot
parent a4e84c9244
commit 9c16bbd023
3 changed files with 41 additions and 17 deletions

View file

@ -110,13 +110,13 @@ run_gs(brw_shader &s)
brw_from_nir(&s); brw_from_nir(&s);
brw_emit_gs_thread_end(s);
if (s.failed) if (s.failed)
return false; return false;
brw_calculate_cfg(s); brw_calculate_cfg(s);
brw_emit_gs_thread_end(s);
brw_optimize(s); brw_optimize(s);
s.assign_curb_setup(); s.assign_curb_setup();

View file

@ -176,13 +176,13 @@ run_tcs(brw_shader &s)
bld.emit(BRW_OPCODE_ENDIF); bld.emit(BRW_OPCODE_ENDIF);
} }
brw_emit_tcs_thread_end(s);
if (s.failed) if (s.failed)
return false; return false;
brw_calculate_cfg(s); brw_calculate_cfg(s);
brw_emit_tcs_thread_end(s);
brw_optimize(s); brw_optimize(s);
s.assign_curb_setup(); s.assign_curb_setup();

View file

@ -578,23 +578,47 @@ brw_barycentric_mode(const struct brw_wm_prog_key *key,
bool bool
brw_shader::mark_last_urb_write_with_eot() brw_shader::mark_last_urb_write_with_eot()
{ {
brw_foreach_in_list_reverse(brw_inst, prev, &this->instructions) { brw_inst *limit = NULL;
if (prev->opcode == SHADER_OPCODE_URB_WRITE_LOGICAL) { foreach_block_reverse(block, cfg) {
prev->eot = true; foreach_inst_in_block_reverse(brw_inst, inst, block) {
if (inst->opcode == SHADER_OPCODE_URB_WRITE_LOGICAL) {
/* Delete now dead instructions. */ inst->eot = true;
brw_foreach_in_list_reverse_safe(brw_exec_node, dead, &this->instructions) { limit = inst;
if (dead == prev) break;
break; } else if (inst->is_control_flow() || inst->has_side_effects()) {
dead->remove(); limit = inst;
break;
} }
return true;
} else if (prev->is_control_flow() || prev->has_side_effects()) {
break;
} }
if (limit)
break;
} }
return false; if (!limit || !limit->eot)
return false;
brw_analysis_dependency_class dep = BRW_DEPENDENCY_INSTRUCTION_DETAIL;
/* Delete now dead instructions. */
bool done = false;
foreach_block_reverse(block, cfg) {
foreach_inst_in_block_reverse_safe(brw_inst, dead, block) {
if (dead == limit) {
done = true;
break;
}
dep = dep | BRW_DEPENDENCY_INSTRUCTION_IDENTITY;
dead->remove();
}
if (done)
break;
}
invalidate_analysis(dep);
return true;
} }
static unsigned static unsigned