intel/compiler: Introduce backend_shader method to propagate IR changes to analysis passes
The invalidate_analysis() method knows what analysis passes there are in the back-end and calls their invalidate() method to report changes in the IR. For the moment it just calls invalidate_live_intervals() (which will eventually be fully replaced by this function) if anything changed. This makes all optimization passes invalidate DEPENDENCY_EVERYTHING, which is clearly far from ideal -- The dependency classes passed to invalidate_analysis() will be refined in a future commit. Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4012>
This commit is contained in:

committed by
Matt Turner

parent
03eb46f4a7
commit
d966a6b4c4
@@ -29,6 +29,8 @@
|
||||
#include "brw_shader.h"
|
||||
#include "brw_cfg.h"
|
||||
|
||||
using namespace brw;
|
||||
|
||||
/* Look for and eliminate dead control flow:
|
||||
*
|
||||
* - if/endif
|
||||
@@ -113,7 +115,7 @@ dead_control_flow_eliminate(backend_shader *s)
|
||||
}
|
||||
|
||||
if (progress)
|
||||
s->invalidate_live_intervals();
|
||||
s->invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -2029,7 +2029,7 @@ fs_visitor::split_virtual_grfs()
|
||||
}
|
||||
}
|
||||
}
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
delete[] split_points;
|
||||
delete[] new_virtual_grf;
|
||||
@@ -2074,7 +2074,7 @@ fs_visitor::compact_virtual_grfs()
|
||||
} else {
|
||||
remap_table[i] = new_index;
|
||||
alloc.sizes[new_index] = alloc.sizes[i];
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
++new_index;
|
||||
}
|
||||
}
|
||||
@@ -2537,7 +2537,7 @@ fs_visitor::lower_constant_loads()
|
||||
inst->remove(block);
|
||||
}
|
||||
}
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -2815,6 +2815,10 @@ fs_visitor::opt_algebraic()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
@@ -2864,7 +2868,7 @@ fs_visitor::opt_zero_samples()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -2961,7 +2965,7 @@ fs_visitor::opt_sampler_eot()
|
||||
* flag and submit a header together with the sampler message as required
|
||||
* by the hardware.
|
||||
*/
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3014,7 +3018,7 @@ fs_visitor::opt_register_renaming()
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(delta_xy); i++) {
|
||||
if (delta_xy[i].file == VGRF && remap[delta_xy[i].nr] != ~0u) {
|
||||
@@ -3062,7 +3066,7 @@ fs_visitor::opt_redundant_discard_jumps()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -3256,7 +3260,7 @@ fs_visitor::compute_to_mrf()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -3313,6 +3317,9 @@ fs_visitor::eliminate_find_live_channel()
|
||||
}
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
@@ -3459,7 +3466,7 @@ fs_visitor::remove_duplicate_mrf_writes()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -3508,7 +3515,7 @@ fs_visitor::remove_extra_rounding_modes()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -3689,7 +3696,7 @@ fs_visitor::insert_gen4_send_dependency_workarounds()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3729,7 +3736,7 @@ fs_visitor::lower_uniform_pull_constant_loads()
|
||||
inst->header_size = 1;
|
||||
inst->mlen = 1;
|
||||
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
} else {
|
||||
/* Before register allocation, we didn't tell the scheduler about the
|
||||
* MRF we use. We know it's safe to use this MRF because nothing
|
||||
@@ -3847,7 +3854,7 @@ fs_visitor::lower_load_payload()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -4147,7 +4154,7 @@ fs_visitor::lower_integer_multiplication()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -4177,7 +4184,7 @@ fs_visitor::lower_minmax()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -4266,7 +4273,7 @@ fs_visitor::lower_sub_sat()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -5978,7 +5985,7 @@ fs_visitor::lower_logical_sends()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -6863,7 +6870,7 @@ fs_visitor::lower_simd_width()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -6944,7 +6951,7 @@ fs_visitor::lower_barycentrics()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -7353,7 +7360,7 @@ fs_visitor::setup_cs_payload()
|
||||
void
|
||||
fs_visitor::calculate_register_pressure()
|
||||
{
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
calculate_live_intervals();
|
||||
|
||||
unsigned num_instructions = 0;
|
||||
@@ -7368,6 +7375,12 @@ fs_visitor::calculate_register_pressure()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::invalidate_analysis(brw::analysis_dependency_class c)
|
||||
{
|
||||
backend_shader::invalidate_analysis(c);
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::optimize()
|
||||
{
|
||||
@@ -7580,7 +7593,7 @@ fs_visitor::fixup_sends_duplicate_payload()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -7603,7 +7616,7 @@ fs_visitor::fixup_3src_null_dest()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7746,7 +7759,7 @@ fs_visitor::fixup_nomask_control_flow()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -126,6 +126,7 @@ public:
|
||||
unsigned *out_pull_index);
|
||||
void lower_constant_loads();
|
||||
void invalidate_live_intervals();
|
||||
virtual void invalidate_analysis(brw::analysis_dependency_class c);
|
||||
void calculate_live_intervals();
|
||||
void calculate_register_pressure();
|
||||
void validate();
|
||||
|
@@ -48,6 +48,8 @@
|
||||
* exists and therefore remove the instruction.
|
||||
*/
|
||||
|
||||
using namespace brw;
|
||||
|
||||
static bool
|
||||
cmod_propagate_cmp_to_add(const gen_device_info *devinfo, bblock_t *block,
|
||||
fs_inst *inst)
|
||||
@@ -446,7 +448,7 @@ fs_visitor::opt_cmod_propagation()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -559,7 +559,7 @@ fs_visitor::opt_combine_constants()
|
||||
}
|
||||
|
||||
ralloc_free(const_ctx);
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1067,7 +1067,7 @@ fs_visitor::opt_copy_propagation()
|
||||
ralloc_free(copy_prop_ctx);
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -389,7 +389,7 @@ fs_visitor::opt_cse()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@
|
||||
* yet in the tail end of this block.
|
||||
*/
|
||||
|
||||
using namespace brw;
|
||||
|
||||
/**
|
||||
* Is it safe to eliminate the instruction?
|
||||
*/
|
||||
@@ -142,7 +144,7 @@ fs_visitor::dead_code_eliminate()
|
||||
ralloc_free(flag_live);
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ fs_visitor::lower_pack()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -454,7 +454,7 @@ fs_visitor::lower_regioning()
|
||||
progress |= lower_instruction(this, block, inst);
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -1208,7 +1208,7 @@ fs_reg_alloc::assign_regs(bool allow_spilling, bool spill_all)
|
||||
}
|
||||
|
||||
if (spilled)
|
||||
fs->invalidate_live_intervals();
|
||||
fs->invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
/* Get the chosen virtual registers for each node, and map virtual
|
||||
* regs in the register classes back down to real hardware reg
|
||||
|
@@ -44,6 +44,8 @@
|
||||
#include "brw_cfg.h"
|
||||
#include "brw_fs_live_variables.h"
|
||||
|
||||
using namespace brw;
|
||||
|
||||
static bool
|
||||
is_nop_mov(const fs_inst *inst)
|
||||
{
|
||||
@@ -288,7 +290,7 @@ fs_visitor::register_coalesce()
|
||||
}
|
||||
}
|
||||
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
@@ -215,7 +215,7 @@ fs_visitor::opt_peephole_sel()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -138,7 +138,7 @@ opt_predicated_break(backend_shader *s)
|
||||
}
|
||||
|
||||
if (progress)
|
||||
s->invalidate_live_intervals();
|
||||
s->invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -1839,7 +1839,7 @@ fs_visitor::schedule_instructions(instruction_scheduler_mode mode)
|
||||
cfg->num_blocks, mode);
|
||||
sched.run(cfg);
|
||||
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1848,5 +1848,5 @@ vec4_visitor::opt_schedule_instructions()
|
||||
vec4_instruction_scheduler sched(this, prog_data->total_grf);
|
||||
sched.run(cfg);
|
||||
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
@@ -1245,6 +1245,13 @@ backend_shader::calculate_cfg()
|
||||
cfg = new(mem_ctx) cfg_t(&this->instructions);
|
||||
}
|
||||
|
||||
void
|
||||
backend_shader::invalidate_analysis(brw::analysis_dependency_class c)
|
||||
{
|
||||
if (c)
|
||||
invalidate_live_intervals();
|
||||
}
|
||||
|
||||
extern "C" const unsigned *
|
||||
brw_compile_tes(const struct brw_compiler *compiler,
|
||||
void *log_data,
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "compiler/nir/nir.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "brw_ir_analysis.h"
|
||||
#include "brw_ir_allocator.h"
|
||||
|
||||
enum instruction_scheduler_mode {
|
||||
@@ -84,6 +85,7 @@ public:
|
||||
void calculate_cfg();
|
||||
|
||||
virtual void invalidate_live_intervals() = 0;
|
||||
virtual void invalidate_analysis(brw::analysis_dependency_class c);
|
||||
};
|
||||
|
||||
bool brw_texture_offset(const nir_tex_instr *tex, unsigned src,
|
||||
|
@@ -496,7 +496,7 @@ vec4_visitor::opt_vector_float()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ vec4_visitor::opt_reduce_swizzle()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -904,7 +904,7 @@ vec4_visitor::opt_algebraic()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -1474,7 +1474,7 @@ vec4_visitor::opt_register_coalesce()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -1524,6 +1524,9 @@ vec4_visitor::eliminate_find_live_channel()
|
||||
}
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
@@ -1598,7 +1601,7 @@ vec4_visitor::split_virtual_grfs()
|
||||
}
|
||||
}
|
||||
}
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1901,7 +1904,7 @@ vec4_visitor::lower_minmax()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -2037,7 +2040,7 @@ vec4_visitor::fixup_3src_null_dest()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2365,7 +2368,7 @@ vec4_visitor::lower_simd_width()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -2522,7 +2525,7 @@ vec4_visitor::scalarize_df()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -2565,7 +2568,7 @@ vec4_visitor::lower_64bit_mad_to_mul_add()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -2662,6 +2665,12 @@ vec4_visitor::apply_logical_swizzle(struct brw_reg *hw_reg,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vec4_visitor::invalidate_analysis(brw::analysis_dependency_class c)
|
||||
{
|
||||
backend_shader::invalidate_analysis(c);
|
||||
}
|
||||
|
||||
bool
|
||||
vec4_visitor::run()
|
||||
{
|
||||
|
@@ -138,6 +138,7 @@ public:
|
||||
void pack_uniform_registers();
|
||||
void calculate_live_intervals();
|
||||
void invalidate_live_intervals();
|
||||
virtual void invalidate_analysis(brw::analysis_dependency_class c);
|
||||
void split_virtual_grfs();
|
||||
bool opt_vector_float();
|
||||
bool opt_reduce_swizzle();
|
||||
|
@@ -357,7 +357,7 @@ vec4_visitor::opt_cmod_propagation()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -559,7 +559,7 @@ vec4_visitor::opt_copy_propagation(bool do_constant_prop)
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -317,7 +317,7 @@ vec4_visitor::opt_cse()
|
||||
}
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -183,7 +183,7 @@ vec4_visitor::dead_code_eliminate()
|
||||
ralloc_free(flag_live);
|
||||
|
||||
if (progress)
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
@@ -540,7 +540,7 @@ vec4_visitor::spill_reg(unsigned spill_reg_nr)
|
||||
}
|
||||
}
|
||||
|
||||
invalidate_live_intervals();
|
||||
invalidate_analysis(DEPENDENCY_EVERYTHING);
|
||||
}
|
||||
|
||||
} /* namespace brw */
|
||||
|
Reference in New Issue
Block a user