Mesa (master): i965/fs: Add a pass to fixup 3-src instructions that have a null dest.

Matt Turner mattst88 at kemper.freedesktop.org
Sat Jan 24 01:56:21 UTC 2015


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Dec 29 20:33:12 2014 -0800

i965/fs: Add a pass to fixup 3-src instructions that have a null dest.

3-src instructions can only have GRF/MRF destinations. It's really
difficult to deal with that restriction in dead code elimination (that
wants to give instructions null destinations to show that their result
isn't used) while allowing 3-src instructions to have conditional mod,
so don't, and just give then a destination before register allocation.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_fs.cpp |   17 +++++++++++++++++
 src/mesa/drivers/dri/i965/brw_fs.h   |    1 +
 2 files changed, 18 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 786e4e0..96be396 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3606,6 +3606,21 @@ fs_visitor::optimize()
    lower_uniform_pull_constant_loads();
 }
 
+/**
+ * Three source instruction must have a GRF/MRF destination register.
+ * ARF NULL is not allowed.  Fix that up by allocating a temporary GRF.
+ */
+void
+fs_visitor::fixup_3src_null_dest()
+{
+   foreach_block_and_inst_safe (block, fs_inst, inst, cfg) {
+      if (inst->is_3src() && inst->dst.is_null()) {
+         inst->dst = fs_reg(GRF, virtual_grf_alloc(dispatch_width / 8),
+                            inst->dst.type);
+      }
+   }
+}
+
 void
 fs_visitor::allocate_registers()
 {
@@ -3703,6 +3718,7 @@ fs_visitor::run_vs()
    assign_curb_setup();
    assign_vs_urb_setup();
 
+   fixup_3src_null_dest();
    allocate_registers();
 
    return !failed;
@@ -3781,6 +3797,7 @@ fs_visitor::run_fs()
       assign_curb_setup();
       assign_urb_setup();
 
+      fixup_3src_null_dest();
       allocate_registers();
 
       if (failed)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 419fe48..b0eb701 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -424,6 +424,7 @@ public:
    void setup_payload_gen4();
    void setup_payload_gen6();
    void setup_vs_payload();
+   void fixup_3src_null_dest();
    void assign_curb_setup();
    void calculate_urb_setup();
    void assign_urb_setup();




More information about the mesa-commit mailing list