From de6a79857794d126962ed981d3c772eb1317fba9 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Wed, 3 Jan 2024 16:39:30 -0800 Subject: [PATCH] intel/brw: Use references for a couple of backend_shader passes This will allow simplify the OPT macro for fs_visitor::optimize(). Reviewed-by: Lionel Landwerlin Reviewed-by: Ian Romanick Part-of: --- src/intel/compiler/brw_dead_control_flow.cpp | 6 +++--- src/intel/compiler/brw_dead_control_flow.h | 2 +- src/intel/compiler/brw_fs.cpp | 4 ++-- src/intel/compiler/brw_predicated_break.cpp | 10 +++++----- src/intel/compiler/brw_shader.h | 4 ++-- src/intel/compiler/brw_vec4.cpp | 4 ++-- src/intel/compiler/test_predicated_break.cpp | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/intel/compiler/brw_dead_control_flow.cpp b/src/intel/compiler/brw_dead_control_flow.cpp index 0d9253bab18..03295f87ce4 100644 --- a/src/intel/compiler/brw_dead_control_flow.cpp +++ b/src/intel/compiler/brw_dead_control_flow.cpp @@ -38,11 +38,11 @@ using namespace brw; * - then in if/else/endif */ bool -dead_control_flow_eliminate(backend_shader *s) +dead_control_flow_eliminate(backend_shader &s) { bool progress = false; - foreach_block_safe (block, s->cfg) { + foreach_block_safe (block, s.cfg) { bblock_t *prev_block = block->prev(); if (!prev_block) @@ -115,7 +115,7 @@ dead_control_flow_eliminate(backend_shader *s) } if (progress) - s->invalidate_analysis(DEPENDENCY_BLOCKS | DEPENDENCY_INSTRUCTIONS); + s.invalidate_analysis(DEPENDENCY_BLOCKS | DEPENDENCY_INSTRUCTIONS); return progress; } diff --git a/src/intel/compiler/brw_dead_control_flow.h b/src/intel/compiler/brw_dead_control_flow.h index 9732c2b9f3f..95f878ebb4e 100644 --- a/src/intel/compiler/brw_dead_control_flow.h +++ b/src/intel/compiler/brw_dead_control_flow.h @@ -26,6 +26,6 @@ #include "brw_shader.h" -bool dead_control_flow_eliminate(backend_shader *s); +bool dead_control_flow_eliminate(backend_shader &s); #endif /* BRW_DEAD_CONTROL_FLOW_H */ diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index c534898102e..b57dd905427 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -5686,11 +5686,11 @@ fs_visitor::optimize() OPT(brw_fs_opt_algebraic, *this); OPT(brw_fs_opt_cse, *this); OPT(brw_fs_opt_copy_propagation, *this); - OPT(opt_predicated_break, this); + OPT(opt_predicated_break, *this); OPT(brw_fs_opt_cmod_propagation, *this); OPT(brw_fs_opt_dead_code_eliminate, *this); OPT(brw_fs_opt_peephole_sel, *this); - OPT(dead_control_flow_eliminate, this); + OPT(dead_control_flow_eliminate, *this); OPT(brw_fs_opt_saturate_propagation, *this); OPT(brw_fs_opt_register_coalesce, *this); OPT(brw_fs_opt_eliminate_find_live_channel, *this); diff --git a/src/intel/compiler/brw_predicated_break.cpp b/src/intel/compiler/brw_predicated_break.cpp index 118d71b3773..8ec7f150f5e 100644 --- a/src/intel/compiler/brw_predicated_break.cpp +++ b/src/intel/compiler/brw_predicated_break.cpp @@ -99,12 +99,12 @@ has_continue(const struct loop_continue_tracking *s) } bool -opt_predicated_break(backend_shader *s) +opt_predicated_break(backend_shader &s) { bool progress = false; struct loop_continue_tracking state = { {0, }, 0 }; - foreach_block (block, s->cfg) { + foreach_block (block, s.cfg) { /* DO instructions, by definition, can only be found at the beginning of * basic blocks. */ @@ -168,7 +168,7 @@ opt_predicated_break(backend_shader *s) earlier_block->start()->opcode != BRW_OPCODE_DO); earlier_block->unlink_children(); - earlier_block->add_successor(s->cfg->mem_ctx, jump_block, + earlier_block->add_successor(s.cfg->mem_ctx, jump_block, bblock_link_logical); } @@ -198,7 +198,7 @@ opt_predicated_break(backend_shader *s) } if (need_to_link) { - jump_block->add_successor(s->cfg->mem_ctx, later_block, + jump_block->add_successor(s.cfg->mem_ctx, later_block, bblock_link_logical); } @@ -237,7 +237,7 @@ opt_predicated_break(backend_shader *s) } if (progress) - s->invalidate_analysis(DEPENDENCY_BLOCKS | DEPENDENCY_INSTRUCTIONS); + s.invalidate_analysis(DEPENDENCY_BLOCKS | DEPENDENCY_INSTRUCTIONS); return progress; } diff --git a/src/intel/compiler/brw_shader.h b/src/intel/compiler/brw_shader.h index 85a1912ee3c..ce666e4ed3b 100644 --- a/src/intel/compiler/brw_shader.h +++ b/src/intel/compiler/brw_shader.h @@ -93,6 +93,8 @@ public: virtual void invalidate_analysis(brw::analysis_dependency_class c); }; +bool opt_predicated_break(backend_shader &s); + #else struct backend_shader; #endif /* __cplusplus */ @@ -105,8 +107,6 @@ bool brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg); bool brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg); bool brw_abs_immediate(enum brw_reg_type type, struct brw_reg *reg); -bool opt_predicated_break(struct backend_shader *s); - #ifdef __cplusplus extern "C" { #endif diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp index cb93f3cc2c6..8abc503d486 100644 --- a/src/intel/compiler/brw_vec4.cpp +++ b/src/intel/compiler/brw_vec4.cpp @@ -2440,10 +2440,10 @@ vec4_visitor::run() pass_num = 0; iteration++; - OPT(opt_predicated_break, this); + OPT(opt_predicated_break, *this); OPT(opt_reduce_swizzle); OPT(dead_code_eliminate); - OPT(dead_control_flow_eliminate, this); + OPT(dead_control_flow_eliminate, *this); OPT(opt_copy_propagation); OPT(opt_cmod_propagation); OPT(opt_cse); diff --git a/src/intel/compiler/test_predicated_break.cpp b/src/intel/compiler/test_predicated_break.cpp index 6289867d037..60d93fe6b5b 100644 --- a/src/intel/compiler/test_predicated_break.cpp +++ b/src/intel/compiler/test_predicated_break.cpp @@ -77,7 +77,7 @@ PredicatedBreakTest::opt_predicated_break(fs_visitor *s) s->cfg->dump(); } - bool ret = ::opt_predicated_break(s); + bool ret = ::opt_predicated_break(*s); if (print) { fprintf(stderr, "\n= After =\n");