intel/fs/ra: Add spill costs to the graph on-demand
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 15 May 2019 04:03:29 +0000 (23:03 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Thu, 16 May 2019 02:13:09 +0000 (02:13 +0000)
Tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/compiler/brw_fs_reg_allocate.cpp

index aeb7214ba38e2a9df6623158d78668908766404d..b7425ea6d58f2f972053486956e7dee30bd9bbea 100644 (file)
@@ -396,7 +396,8 @@ void fs_visitor::calculate_payload_ranges(int payload_node_count,
 class fs_reg_alloc {
 public:
    fs_reg_alloc(fs_visitor *fs):
-      fs(fs), devinfo(fs->devinfo), compiler(fs->compiler), g(NULL)
+      fs(fs), devinfo(fs->devinfo), compiler(fs->compiler), g(NULL),
+      have_spill_costs(false)
    {
       mem_ctx = ralloc_context(NULL);
 
@@ -447,6 +448,7 @@ private:
    int rsi;
 
    ra_graph *g;
+   bool have_spill_costs;
 
    int payload_node_count;
    int *payload_last_use_ip;
@@ -796,9 +798,6 @@ fs_reg_alloc::build_interference_graph(bool allow_spilling)
     */
    foreach_block_and_inst(block, fs_inst, inst, fs->cfg)
       setup_inst_interference(inst);
-
-   if (allow_spilling)
-      set_spill_costs();
 }
 
 void
@@ -806,6 +805,7 @@ fs_reg_alloc::discard_interference_graph()
 {
    ralloc_free(g);
    g = NULL;
+   have_spill_costs = false;
 }
 
 static void
@@ -937,11 +937,16 @@ fs_reg_alloc::set_spill_costs()
       if (!no_spill[i])
         ra_set_node_spill_cost(g, first_vgrf_node + i, adjusted_cost);
    }
+
+   have_spill_costs = true;
 }
 
 int
 fs_reg_alloc::choose_spill_reg()
 {
+   if (!have_spill_costs)
+      set_spill_costs();
+
    int node = ra_get_best_spill_node(g);
    if (node < 0)
       return -1;