Mesa (master): i965/fs: Refactor compute_to_mrf() to split search and rewrite into separate loops.

Francisco Jerez currojerez at kemper.freedesktop.org
Tue May 31 22:58:54 UTC 2016


Module: Mesa
Branch: master
Commit: 485fbaff03f7d281ff4f22bd6321548512783799
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=485fbaff03f7d281ff4f22bd6321548512783799

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Fri May 27 13:15:55 2016 -0700

i965/fs: Refactor compute_to_mrf() to split search and rewrite into separate loops.

This will allow compute_to_mrf to handle cases where the source of the
VGRF-to-MRF copy is initialized by more than one instruction.  In such
cases we cannot rewrite the destination of any of the generating
instructions until it's known whether the whole VGRF source region can
be coalesced into the destination MRF, which will imply continuing the
search until all generating instructions have been found or it has
been determined that the VGRF and MRF registers cannot be coalesced.

Cc: "12.0" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/mesa/drivers/dri/i965/brw_fs.cpp | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index b521f90..bb36a8e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2801,6 +2801,8 @@ fs_visitor::compute_to_mrf()
       /* Found a move of a GRF to a MRF.  Let's see if we can go
        * rewrite the thing that made this GRF to write into the MRF.
        */
+      bool found = false;
+
       foreach_inst_in_block_reverse_starting_from(fs_inst, scan_inst, inst) {
          if (regions_overlap(scan_inst->dst, scan_inst->regs_written * REG_SIZE,
                              inst->src[0], inst->regs_read(0) * REG_SIZE)) {
@@ -2811,7 +2813,7 @@ fs_visitor::compute_to_mrf()
 	    /* If this one instruction didn't populate all the
 	     * channels, bail.  We might be able to rewrite everything
 	     * that writes that reg, but it would require smarter
-	     * tracking to delay the rewriting until complete success.
+	     * tracking.
 	     */
 	    if (scan_inst->is_partial_write())
 	       break;
@@ -2838,15 +2840,9 @@ fs_visitor::compute_to_mrf()
 	       }
 	    }
 
-	    if (scan_inst->dst.reg_offset == inst->src[0].reg_offset) {
-	       /* Found the creator of our MRF's source value. */
-	       scan_inst->dst.file = MRF;
-               scan_inst->dst.nr = inst->dst.nr;
-               scan_inst->dst.reg_offset = 0;
-	       scan_inst->saturate |= inst->saturate;
-	       inst->remove(block);
-	       progress = true;
-	    }
+	    if (scan_inst->dst.reg_offset == inst->src[0].reg_offset)
+               found = true;
+
 	    break;
 	 }
 
@@ -2889,6 +2885,25 @@ fs_visitor::compute_to_mrf()
             break;
          }
       }
+
+      if (!found)
+         continue;
+
+      /* Found all generating instructions of our MRF's source value.
+       */
+      foreach_inst_in_block_reverse_starting_from(fs_inst, scan_inst, inst) {
+         if (regions_overlap(scan_inst->dst, scan_inst->regs_written * REG_SIZE,
+                             inst->src[0], inst->regs_read(0) * REG_SIZE)) {
+            scan_inst->dst.file = MRF;
+            scan_inst->dst.nr = inst->dst.nr;
+            scan_inst->dst.reg_offset = 0;
+            scan_inst->saturate |= inst->saturate;
+            break;
+         }
+      }
+
+      inst->remove(block);
+      progress = true;
    }
 
    if (progress)




More information about the mesa-commit mailing list