i965/fs: Make compact_virtual_grfs an optimization pass
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 16 Sep 2014 20:14:09 +0000 (13:14 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 30 Sep 2014 17:29:13 +0000 (10:29 -0700)
Previously we disabled compact_virtual_grfs when dumping optimizations.
The idea here was to make it easier to diff the dumped shader because you
didn't have a sudden renaming.  However, sometimes a bug is affected by
compact_virtual_grfs and, when this happens, you want to keep dumping
instructions with compact_virtual_grfs enabled.  By turning it into an
optimization pass and dumping it along with the others, we retain the
ability to diff because you can just diff against the compact_virtual_grf
output.

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h

index bd862abb8966e7a0dbf76f27a2d1725e9b6985f1..eebc31c95644494e23d6192229e26349f0e4c616 100644 (file)
@@ -1770,12 +1770,10 @@ fs_visitor::split_virtual_grfs()
  * to loop over all the virtual GRFs.  Compacting them can save a lot of
  * overhead.
  */
-void
+bool
 fs_visitor::compact_virtual_grfs()
 {
-   if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER))
-      return;
-
+   bool progress = false;
    int remap_table[this->virtual_grf_count];
    memset(remap_table, -1, sizeof(remap_table));
 
@@ -1793,7 +1791,12 @@ fs_visitor::compact_virtual_grfs()
    /* Compact the GRF arrays. */
    int new_index = 0;
    for (int i = 0; i < this->virtual_grf_count; i++) {
-      if (remap_table[i] != -1) {
+      if (remap_table[i] == -1) {
+         /* We just found an unused register.  This means that we are
+          * actually going to compact something.
+          */
+         progress = true;
+      } else {
          remap_table[i] = new_index;
          virtual_grf_sizes[new_index] = virtual_grf_sizes[i];
          invalidate_live_intervals();
@@ -1836,6 +1839,8 @@ fs_visitor::compact_virtual_grfs()
          }
       }
    }
+
+   return progress;
 }
 
 /*
@@ -3276,8 +3281,6 @@ fs_visitor::run()
          iteration++;
          int pass_num = 0;
 
-         compact_virtual_grfs();
-
          OPT(remove_duplicate_mrf_writes);
 
          OPT(opt_algebraic);
@@ -3291,6 +3294,8 @@ fs_visitor::run()
          OPT(opt_saturate_propagation);
          OPT(register_coalesce);
          OPT(compute_to_mrf);
+
+         OPT(compact_virtual_grfs);
       } while (progress);
 
       if (lower_load_payload()) {
index f0da0a014d72af05411931383a32b29bbfa83d1d..ba40801d488c9500973d3fc33078238cdd85843b 100644 (file)
@@ -325,7 +325,7 @@ public:
    int choose_spill_reg(struct ra_graph *g);
    void spill_reg(int spill_reg);
    void split_virtual_grfs();
-   void compact_virtual_grfs();
+   bool compact_virtual_grfs();
    void move_uniform_array_access_to_pull_constants();
    void assign_constant_locations();
    void demote_pull_constants();