From: Francisco Jerez Date: Sun, 13 Mar 2016 02:50:24 +0000 (-0800) Subject: intel/compiler: Introduce backend_shader method to propagate IR changes to analysis... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d966a6b4c4684bc02647a8fdc69a6c88e5ed00c2;p=mesa.git 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 Part-of: --- diff --git a/src/intel/compiler/brw_dead_control_flow.cpp b/src/intel/compiler/brw_dead_control_flow.cpp index 114dc6cb212..a52bb233d26 100644 --- a/src/intel/compiler/brw_dead_control_flow.cpp +++ b/src/intel/compiler/brw_dead_control_flow.cpp @@ -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; } diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 10a73251a44..6e79405165e 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -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; } diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index c4af8e9d709..ee04eba52cf 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -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(); diff --git a/src/intel/compiler/brw_fs_cmod_propagation.cpp b/src/intel/compiler/brw_fs_cmod_propagation.cpp index 45ea9206014..9f35c13dd6f 100644 --- a/src/intel/compiler/brw_fs_cmod_propagation.cpp +++ b/src/intel/compiler/brw_fs_cmod_propagation.cpp @@ -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; } diff --git a/src/intel/compiler/brw_fs_combine_constants.cpp b/src/intel/compiler/brw_fs_combine_constants.cpp index d10ac0219cf..ebedbb4cdf6 100644 --- a/src/intel/compiler/brw_fs_combine_constants.cpp +++ b/src/intel/compiler/brw_fs_combine_constants.cpp @@ -559,7 +559,7 @@ fs_visitor::opt_combine_constants() } ralloc_free(const_ctx); - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return true; } diff --git a/src/intel/compiler/brw_fs_copy_propagation.cpp b/src/intel/compiler/brw_fs_copy_propagation.cpp index 03882b38dfb..c75bdac81ee 100644 --- a/src/intel/compiler/brw_fs_copy_propagation.cpp +++ b/src/intel/compiler/brw_fs_copy_propagation.cpp @@ -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; } diff --git a/src/intel/compiler/brw_fs_cse.cpp b/src/intel/compiler/brw_fs_cse.cpp index f02914e04f3..97a8e146013 100644 --- a/src/intel/compiler/brw_fs_cse.cpp +++ b/src/intel/compiler/brw_fs_cse.cpp @@ -389,7 +389,7 @@ fs_visitor::opt_cse() } if (progress) - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_fs_dead_code_eliminate.cpp b/src/intel/compiler/brw_fs_dead_code_eliminate.cpp index f3d510d36d0..d1b2d907bdc 100644 --- a/src/intel/compiler/brw_fs_dead_code_eliminate.cpp +++ b/src/intel/compiler/brw_fs_dead_code_eliminate.cpp @@ -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; } diff --git a/src/intel/compiler/brw_fs_lower_pack.cpp b/src/intel/compiler/brw_fs_lower_pack.cpp index 7afaae095bd..011a326ac1e 100644 --- a/src/intel/compiler/brw_fs_lower_pack.cpp +++ b/src/intel/compiler/brw_fs_lower_pack.cpp @@ -49,7 +49,7 @@ fs_visitor::lower_pack() } if (progress) - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_fs_lower_regioning.cpp b/src/intel/compiler/brw_fs_lower_regioning.cpp index 98699c38d84..24542584ce4 100644 --- a/src/intel/compiler/brw_fs_lower_regioning.cpp +++ b/src/intel/compiler/brw_fs_lower_regioning.cpp @@ -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; } diff --git a/src/intel/compiler/brw_fs_reg_allocate.cpp b/src/intel/compiler/brw_fs_reg_allocate.cpp index b26f10ea44e..ffc3f21af72 100644 --- a/src/intel/compiler/brw_fs_reg_allocate.cpp +++ b/src/intel/compiler/brw_fs_reg_allocate.cpp @@ -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 diff --git a/src/intel/compiler/brw_fs_register_coalesce.cpp b/src/intel/compiler/brw_fs_register_coalesce.cpp index 8127b29369c..8a87619dbe1 100644 --- a/src/intel/compiler/brw_fs_register_coalesce.cpp +++ b/src/intel/compiler/brw_fs_register_coalesce.cpp @@ -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; diff --git a/src/intel/compiler/brw_fs_sel_peephole.cpp b/src/intel/compiler/brw_fs_sel_peephole.cpp index 6395b409b7c..5343d98d90e 100644 --- a/src/intel/compiler/brw_fs_sel_peephole.cpp +++ b/src/intel/compiler/brw_fs_sel_peephole.cpp @@ -215,7 +215,7 @@ fs_visitor::opt_peephole_sel() } if (progress) - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_predicated_break.cpp b/src/intel/compiler/brw_predicated_break.cpp index df352a64871..cc29b029b45 100644 --- a/src/intel/compiler/brw_predicated_break.cpp +++ b/src/intel/compiler/brw_predicated_break.cpp @@ -138,7 +138,7 @@ opt_predicated_break(backend_shader *s) } if (progress) - s->invalidate_live_intervals(); + s->invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_schedule_instructions.cpp b/src/intel/compiler/brw_schedule_instructions.cpp index 9c78944cf68..826f2e771e3 100644 --- a/src/intel/compiler/brw_schedule_instructions.cpp +++ b/src/intel/compiler/brw_schedule_instructions.cpp @@ -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); } diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index 0a3c3739aa2..14f0eb311f2 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -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, diff --git a/src/intel/compiler/brw_shader.h b/src/intel/compiler/brw_shader.h index 4455f079071..2ab20a72f49 100644 --- a/src/intel/compiler/brw_shader.h +++ b/src/intel/compiler/brw_shader.h @@ -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, diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp index b6246d7742a..18676d4c4ca 100644 --- a/src/intel/compiler/brw_vec4.cpp +++ b/src/intel/compiler/brw_vec4.cpp @@ -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() { diff --git a/src/intel/compiler/brw_vec4.h b/src/intel/compiler/brw_vec4.h index e014e73995b..fb44372f2dd 100644 --- a/src/intel/compiler/brw_vec4.h +++ b/src/intel/compiler/brw_vec4.h @@ -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(); diff --git a/src/intel/compiler/brw_vec4_cmod_propagation.cpp b/src/intel/compiler/brw_vec4_cmod_propagation.cpp index a7a3bb8fb06..5123f2cf6bd 100644 --- a/src/intel/compiler/brw_vec4_cmod_propagation.cpp +++ b/src/intel/compiler/brw_vec4_cmod_propagation.cpp @@ -357,7 +357,7 @@ vec4_visitor::opt_cmod_propagation() } if (progress) - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_vec4_copy_propagation.cpp b/src/intel/compiler/brw_vec4_copy_propagation.cpp index 8c935b3e549..68087339c55 100644 --- a/src/intel/compiler/brw_vec4_copy_propagation.cpp +++ b/src/intel/compiler/brw_vec4_copy_propagation.cpp @@ -559,7 +559,7 @@ vec4_visitor::opt_copy_propagation(bool do_constant_prop) } if (progress) - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_vec4_cse.cpp b/src/intel/compiler/brw_vec4_cse.cpp index c9cf54c6f75..d0dbd23ff07 100644 --- a/src/intel/compiler/brw_vec4_cse.cpp +++ b/src/intel/compiler/brw_vec4_cse.cpp @@ -317,7 +317,7 @@ vec4_visitor::opt_cse() } if (progress) - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_vec4_dead_code_eliminate.cpp b/src/intel/compiler/brw_vec4_dead_code_eliminate.cpp index 99e4c9cacaf..730d4349443 100644 --- a/src/intel/compiler/brw_vec4_dead_code_eliminate.cpp +++ b/src/intel/compiler/brw_vec4_dead_code_eliminate.cpp @@ -183,7 +183,7 @@ vec4_visitor::dead_code_eliminate() ralloc_free(flag_live); if (progress) - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); return progress; } diff --git a/src/intel/compiler/brw_vec4_reg_allocate.cpp b/src/intel/compiler/brw_vec4_reg_allocate.cpp index 3e3791574db..34514a46db9 100644 --- a/src/intel/compiler/brw_vec4_reg_allocate.cpp +++ b/src/intel/compiler/brw_vec4_reg_allocate.cpp @@ -540,7 +540,7 @@ vec4_visitor::spill_reg(unsigned spill_reg_nr) } } - invalidate_live_intervals(); + invalidate_analysis(DEPENDENCY_EVERYTHING); } } /* namespace brw */