OSDN Git Service

i965/fs: Add a pass to fixup 3-src instructions that have a null dest.
authorMatt Turner <mattst88@gmail.com>
Tue, 30 Dec 2014 04:33:12 +0000 (20:33 -0800)
committerMatt Turner <mattst88@gmail.com>
Sat, 24 Jan 2015 01:57:39 +0000 (17:57 -0800)
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@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h

index 786e4e0..96be396 100644 (file)
@@ -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)
index 419fe48..b0eb701 100644 (file)
@@ -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();