i965: Mark delta_x/y as BAD_FILE if remapped away completely.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 13 Sep 2014 00:45:30 +0000 (17:45 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 16 Sep 2014 07:46:46 +0000 (00:46 -0700)
Commit afe3d1556f6b77031f7025309511a0eea2a3e8df (i965: Stop doing
remapping of "special" regs.) stopped remapping delta_x/delta_y, and
additionally stopped considering them always-live.  We later realized
delta_x was used in register allocaiton, so we actually needed to remap
it, which was fixed in commit 23d782067ae834ad53522b46638ea21c62e94ca3
(i965/fs: Keep track of the register that hold delta_x/delta_y.).

However, that commit didn't restore the "always consider it live" part.
If all the code using delta_x was eliminated, fs_visitor::delta_x would
be left pointing at its old register number.  Later code in register
allocation would handle that register number specially...even though it
wasn't actually delta_x.

To combat this, set delta_x/y to BAD_FILE if they're eliminated, and
check for that.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83127
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Cc: "10.3" <mesa-stable@lists.freedesktop.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp

index 2f23a9c7aac3ba269a6420ad6aeb022e75c2c4cf..fa95c818e983048a6dc1fbb7612bb33cf55da9ef 100644 (file)
@@ -1759,16 +1759,25 @@ fs_visitor::compact_virtual_grfs()
    }
 
    /* Patch all the references to delta_x/delta_y, since they're used in
-    * register allocation.
+    * register allocation.  If they're unused, switch them to BAD_FILE so
+    * we don't think some random VGRF is delta_x/delta_y.
     */
    for (unsigned i = 0; i < ARRAY_SIZE(delta_x); i++) {
-      if (delta_x[i].file == GRF && remap_table[delta_x[i].reg] != -1) {
-         delta_x[i].reg = remap_table[delta_x[i].reg];
+      if (delta_x[i].file == GRF) {
+         if (remap_table[delta_x[i].reg] != -1) {
+            delta_x[i].reg = remap_table[delta_x[i].reg];
+         } else {
+            delta_x[i].file = BAD_FILE;
+         }
       }
    }
    for (unsigned i = 0; i < ARRAY_SIZE(delta_y); i++) {
-      if (delta_y[i].file == GRF && remap_table[delta_y[i].reg] != -1) {
-         delta_y[i].reg = remap_table[delta_y[i].reg];
+      if (delta_y[i].file == GRF) {
+         if (remap_table[delta_y[i].reg] != -1) {
+            delta_y[i].reg = remap_table[delta_y[i].reg];
+         } else {
+            delta_y[i].file = BAD_FILE;
+         }
       }
    }
 }
index a9bff65ea01c83cbede170a1875bb0291c789fc0..237cc497433dc19c776f49138a79730c5afe9357 100644 (file)
@@ -459,6 +459,7 @@ fs_visitor::assign_regs(bool allow_spilling)
        * that register and set it to the appropriate class.
        */
       if (screen->wm_reg_sets[rsi].aligned_pairs_class >= 0 &&
+          this->delta_x[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC].file == GRF &&
           this->delta_x[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC].reg == i) {
          c = screen->wm_reg_sets[rsi].aligned_pairs_class;
       }