From 2e90d1fb62a6ef53c15eff76e242c510145178a9 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 28 Jun 2014 20:02:51 -0700 Subject: [PATCH] i965/fs: Pass cfg to calculate_live_intervals(). We've often created the CFG immediately before, so use it when available. Reviewed-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_fs.h | 2 +- src/mesa/drivers/dri/i965/brw_fs_cse.cpp | 3 +-- src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp | 12 ++++++++---- src/mesa/drivers/dri/i965/brw_fs_live_variables.h | 4 ++-- src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 58e7175..961c56c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -373,7 +373,7 @@ public: void assign_constant_locations(); void demote_pull_constants(); void invalidate_live_intervals(); - void calculate_live_intervals(); + void calculate_live_intervals(const cfg_t *cfg = NULL); void calculate_register_pressure(); bool opt_algebraic(); bool opt_cse(); diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp index 381c569..5727801 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp @@ -317,9 +317,8 @@ fs_visitor::opt_cse() { bool progress = false; - calculate_live_intervals(); - cfg_t cfg(&instructions); + calculate_live_intervals(&cfg); for (int b = 0; b < cfg.num_blocks; b++) { bblock_t *block = cfg.blocks[b]; diff --git a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp index 7b2d4aa..d41a42c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp @@ -41,7 +41,7 @@ fs_visitor::dead_code_eliminate() cfg_t cfg(&instructions); - calculate_live_intervals(); + calculate_live_intervals(&cfg); int num_vars = live_intervals->num_vars; BITSET_WORD *live = ralloc_array(NULL, BITSET_WORD, BITSET_WORDS(num_vars)); diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp index 0973dc9..585dc3d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp @@ -243,7 +243,7 @@ fs_live_variables::var_from_reg(fs_reg *reg) return var_from_vgrf[reg->reg] + reg->reg_offset; } -fs_live_variables::fs_live_variables(fs_visitor *v, cfg_t *cfg) +fs_live_variables::fs_live_variables(fs_visitor *v, const cfg_t *cfg) : v(v), cfg(cfg) { mem_ctx = ralloc_context(NULL); @@ -304,7 +304,7 @@ fs_visitor::invalidate_live_intervals() * information about whole VGRFs. */ void -fs_visitor::calculate_live_intervals() +fs_visitor::calculate_live_intervals(const cfg_t *cfg) { if (this->live_intervals) return; @@ -320,8 +320,12 @@ fs_visitor::calculate_live_intervals() virtual_grf_end[i] = -1; } - cfg_t cfg(&instructions); - this->live_intervals = new(mem_ctx) fs_live_variables(this, &cfg); + if (cfg) { + this->live_intervals = new(mem_ctx) fs_live_variables(this, cfg); + } else { + cfg_t cfg(&instructions); + this->live_intervals = new(mem_ctx) fs_live_variables(this, &cfg); + } /* Merge the per-component live ranges to whole VGRF live ranges. */ for (int i = 0; i < live_intervals->num_vars; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h index 5a7dd27..13c3eb4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h +++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h @@ -57,7 +57,7 @@ class fs_live_variables { public: DECLARE_RALLOC_CXX_OPERATORS(fs_live_variables) - fs_live_variables(fs_visitor *v, cfg_t *cfg); + fs_live_variables(fs_visitor *v, const cfg_t *cfg); ~fs_live_variables(); bool vars_interfere(int a, int b); @@ -97,7 +97,7 @@ protected: void compute_start_end(); fs_visitor *v; - cfg_t *cfg; + const cfg_t *cfg; void *mem_ctx; }; diff --git a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp index 079eb2e..1287adb 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp @@ -93,10 +93,10 @@ fs_visitor::opt_saturate_propagation() { bool progress = false; - calculate_live_intervals(); - cfg_t cfg(&instructions); + calculate_live_intervals(&cfg); + for (int b = 0; b < cfg.num_blocks; b++) { progress = opt_saturate_propagation_local(this, cfg.blocks[b]) || progress; -- 2.7.4