[Mesa-dev] [PATCH 06/11] i965: Share the predicate field between FS and VS.

Eric Anholt eric at anholt.net
Thu Oct 4 16:07:43 PDT 2012


Note that BRW_PREDICATE_NONE is 0 and BRW_PREDICATE_NORMAL is 1, so that's a
lot like the true/false we had in the FS before.
---
 src/mesa/drivers/dri/i965/brw_cfg.cpp                |    4 ++--
 src/mesa/drivers/dri/i965/brw_fs.cpp                 |   18 +++++++++---------
 src/mesa/drivers/dri/i965/brw_fs.h                   |    2 --
 .../drivers/dri/i965/brw_fs_copy_propagation.cpp     |    2 +-
 src/mesa/drivers/dri/i965/brw_fs_cse.cpp             |    2 +-
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp            |    2 +-
 src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp  |    2 +-
 src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp    |    2 +-
 .../dri/i965/brw_fs_schedule_instructions.cpp        |    4 ++--
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp         |   16 ++++++++--------
 src/mesa/drivers/dri/i965/brw_shader.h               |    3 +++
 src/mesa/drivers/dri/i965/brw_vec4.h                 |    2 --
 12 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp
index 539cb08..8382764 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
@@ -171,7 +171,7 @@ cfg_t::cfg_t(fs_visitor *v)
 
 	 next = new_block();
 	 next->start = (fs_inst *)inst->next;
-	 if (inst->predicated)
+	 if (inst->predicate)
 	    cur->add_successor(mem_ctx, next);
 
 	 set_next_block(next);
@@ -182,7 +182,7 @@ cfg_t::cfg_t(fs_visitor *v)
 
 	 next = new_block();
 	 next->start = (fs_inst *)inst->next;
-	 if (inst->predicated)
+	 if (inst->predicate)
 	    cur->add_successor(mem_ctx, next);
 
 	 set_next_block(next);
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index aea11ee..0887040 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -141,7 +141,7 @@ fs_inst::equals(fs_inst *inst)
            src[1].equals(inst->src[1]) &&
            src[2].equals(inst->src[2]) &&
            saturate == inst->saturate &&
-           predicated == inst->predicated &&
+           predicate == inst->predicate &&
            conditional_mod == inst->conditional_mod &&
            mlen == inst->mlen &&
            base_mrf == inst->base_mrf &&
@@ -736,7 +736,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
                      emit(FS_OPCODE_MOV_DISPATCH_TO_FLAGS, attr);
                      fs_inst *inst = emit_linterp(attr, fs_reg(interp),
                                                   interpolation_mode, false);
-                     inst->predicated = true;
+                     inst->predicate = BRW_PREDICATE_NORMAL;
                      inst->predicate_inverse = true;
                   }
 		  if (intel->gen < 6) {
@@ -1267,7 +1267,7 @@ fs_visitor::propagate_constants()
       fs_inst *inst = (fs_inst *)node;
 
       if (inst->opcode != BRW_OPCODE_MOV ||
-	  inst->predicated ||
+	  inst->predicate ||
 	  inst->dst.file != GRF || inst->src[0].file != IMM ||
 	  inst->dst.type != inst->src[0].type ||
 	  (c->dispatch_width == 16 &&
@@ -1490,7 +1490,7 @@ fs_visitor::register_coalesce_2()
       fs_inst *inst = (fs_inst *)node;
 
       if (inst->opcode != BRW_OPCODE_MOV ||
-	  inst->predicated ||
+	  inst->predicate ||
 	  inst->saturate ||
 	  inst->src[0].file != GRF ||
 	  inst->src[0].negate ||
@@ -1570,7 +1570,7 @@ fs_visitor::register_coalesce()
 	 continue;
 
       if (inst->opcode != BRW_OPCODE_MOV ||
-	  inst->predicated ||
+	  inst->predicate ||
 	  inst->saturate ||
 	  inst->dst.file != GRF || (inst->src[0].file != GRF &&
 				    inst->src[0].file != UNIFORM)||
@@ -1671,7 +1671,7 @@ fs_visitor::compute_to_mrf()
       next_ip++;
 
       if (inst->opcode != BRW_OPCODE_MOV ||
-	  inst->predicated ||
+	  inst->predicate ||
 	  inst->dst.file != MRF || inst->src[0].file != GRF ||
 	  inst->dst.type != inst->src[0].type ||
 	  inst->src[0].abs || inst->src[0].negate || inst->src[0].smear != -1)
@@ -1720,7 +1720,7 @@ fs_visitor::compute_to_mrf()
 	     * that writes that reg, but it would require smarter
 	     * tracking to delay the rewriting until complete success.
 	     */
-	    if (scan_inst->predicated)
+	    if (scan_inst->predicate)
 	       break;
 
 	    /* If it's half of register setup and not the same half as
@@ -1897,7 +1897,7 @@ fs_visitor::remove_duplicate_mrf_writes()
       if (inst->opcode == BRW_OPCODE_MOV &&
 	  inst->dst.file == MRF &&
 	  inst->src[0].file == GRF &&
-	  !inst->predicated) {
+	  !inst->predicate) {
 	 last_mrf_move[inst->dst.reg] = inst;
       }
    }
@@ -1927,7 +1927,7 @@ fs_visitor::get_instruction_generating_reg(fs_inst *start,
 					   fs_reg reg)
 {
    if (end == start ||
-       end->predicated ||
+       end->predicate ||
        end->force_uncompressed ||
        end->force_sechalf ||
        !reg.equals(end->dst)) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 311d88e..7ed81a7 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -158,8 +158,6 @@ public:
    fs_reg dst;
    fs_reg src[3];
    bool saturate;
-   bool predicated;
-   bool predicate_inverse;
    int conditional_mod; /**< BRW_CONDITIONAL_* */
 
    int mlen; /**< SEND message length */
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index f9606bf..64e28c3 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -117,7 +117,7 @@ fs_visitor::opt_copy_propagate_local(void *mem_ctx,
 	   inst->src[0].file == UNIFORM) &&
 	  inst->src[0].type == inst->dst.type &&
 	  !inst->saturate &&
-	  !inst->predicated &&
+	  !inst->predicate &&
 	  !inst->force_uncompressed &&
 	  !inst->force_sechalf &&
 	  inst->src[0].smear == -1) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index a231868..4958433 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -92,7 +92,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
 	inst = (fs_inst *) inst->next) {
 
       /* Skip some cases. */
-      if (is_expression(inst) && !inst->predicated && inst->mlen == 0 &&
+      if (is_expression(inst) && !inst->predicate && inst->mlen == 0 &&
           !inst->force_uncompressed && !inst->force_sechalf &&
           !inst->conditional_mod)
       {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
index c354d53..c7c8c69 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
@@ -789,7 +789,7 @@ fs_visitor::generate_code()
       dst = brw_reg_from_fs_reg(&inst->dst);
 
       brw_set_conditionalmod(p, inst->conditional_mod);
-      brw_set_predicate_control(p, inst->predicated);
+      brw_set_predicate_control(p, inst->predicate);
       brw_set_predicate_inverse(p, inst->predicate_inverse);
       brw_set_saturate(p, inst->saturate);
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index f41d633..b006514 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -78,7 +78,7 @@ fs_live_variables::setup_def_use()
 	  */
 	 if (inst->dst.file == GRF &&
 	     inst->regs_written() == v->virtual_grf_sizes[inst->dst.reg] &&
-	     !inst->predicated &&
+	     !inst->predicate &&
 	     !inst->force_uncompressed &&
 	     !inst->force_sechalf) {
 	    int reg = inst->dst.reg;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index e3abbe8..5a0f8f3 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -547,7 +547,7 @@ fs_visitor::spill_reg(int spill_reg)
           * inst->regs_written(), then we need to unspill the destination
           * since we write back out all of the regs_written().
 	  */
-	 if (inst->predicated || inst->force_uncompressed || inst->force_sechalf) {
+	 if (inst->predicate || inst->force_uncompressed || inst->force_sechalf) {
             fs_reg unspill_reg = inst->dst;
             for (int chan = 0; chan < inst->regs_written(); chan++) {
                emit_unspill(inst, unspill_reg,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp
index c8eeb41..11e9858 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp
@@ -298,7 +298,7 @@ instruction_scheduler::calculate_deps()
 	 add_dep(last_mrf_write[inst->base_mrf + i], n);
       }
 
-      if (inst->predicated) {
+      if (inst->predicate) {
 	 assert(last_conditional_mod);
 	 add_dep(last_conditional_mod, n);
       }
@@ -382,7 +382,7 @@ instruction_scheduler::calculate_deps()
 	 add_dep(n, last_mrf_write[inst->base_mrf + i], 2);
       }
 
-      if (inst->predicated) {
+      if (inst->predicate) {
 	 add_dep(n, last_conditional_mod);
       }
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index ba77857..3ca28fe 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -311,12 +311,12 @@ fs_visitor::visit(ir_expression *ir)
       inst = emit(BRW_OPCODE_CMP, reg_null_f, op[0], fs_reg(0.0f));
       inst->conditional_mod = BRW_CONDITIONAL_G;
       inst = emit(BRW_OPCODE_MOV, this->result, fs_reg(1.0f));
-      inst->predicated = true;
+      inst->predicate = BRW_PREDICATE_NORMAL;
 
       inst = emit(BRW_OPCODE_CMP, reg_null_f, op[0], fs_reg(0.0f));
       inst->conditional_mod = BRW_CONDITIONAL_L;
       inst = emit(BRW_OPCODE_MOV, this->result, fs_reg(-1.0f));
-      inst->predicated = true;
+      inst->predicate = BRW_PREDICATE_NORMAL;
 
       break;
    case ir_unop_rcp:
@@ -528,7 +528,7 @@ fs_visitor::visit(ir_expression *ir)
 	 inst->conditional_mod = BRW_CONDITIONAL_L;
 
 	 inst = emit(BRW_OPCODE_SEL, this->result, op[0], op[1]);
-	 inst->predicated = true;
+	 inst->predicate = BRW_PREDICATE_NORMAL;
       }
       break;
    case ir_binop_max:
@@ -546,7 +546,7 @@ fs_visitor::visit(ir_expression *ir)
 	 inst->conditional_mod = BRW_CONDITIONAL_G;
 
 	 inst = emit(BRW_OPCODE_SEL, this->result, op[0], op[1]);
-	 inst->predicated = true;
+	 inst->predicate = BRW_PREDICATE_NORMAL;
       }
       break;
 
@@ -633,7 +633,7 @@ fs_visitor::emit_assignment_writes(fs_reg &l, fs_reg &r,
 
 	 if (predicated || !l.equals(r)) {
 	    fs_inst *inst = emit(BRW_OPCODE_MOV, l, r);
-	    inst->predicated = predicated;
+	    inst->predicate = predicated ? BRW_PREDICATE_NORMAL : BRW_PREDICATE_NONE;
 	 }
 
 	 l.reg_offset++;
@@ -734,7 +734,7 @@ fs_visitor::visit(ir_assignment *ir)
 	 if (ir->write_mask & (1 << i)) {
 	    inst = emit(BRW_OPCODE_MOV, l, r);
 	    if (ir->condition)
-	       inst->predicated = true;
+	       inst->predicate = BRW_PREDICATE_NORMAL;
 	    r.reg_offset++;
 	 }
 	 l.reg_offset++;
@@ -1689,7 +1689,7 @@ fs_visitor::visit(ir_if *ir)
       emit_bool_to_cond_code(ir->condition);
 
       inst = emit(BRW_OPCODE_IF);
-      inst->predicated = true;
+      inst->predicate = BRW_PREDICATE_NORMAL;
    }
 
    foreach_list(node, &ir->then_instructions) {
@@ -1746,7 +1746,7 @@ fs_visitor::visit(ir_loop *ir)
       inst->conditional_mod = brw_conditional_for_comparison(ir->cmp);
 
       inst = emit(BRW_OPCODE_BREAK);
-      inst->predicated = true;
+      inst->predicate = BRW_PREDICATE_NORMAL;
    }
 
    foreach_list(node, &ir->body_instructions) {
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index da2b738..0abc667 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -30,6 +30,9 @@
 class backend_instruction : public exec_node {
 public:
    enum opcode opcode; /* BRW_OPCODE_* or FS_OPCODE_* */
+
+   uint32_t predicate;
+   bool predicate_inverse;
 };
 
 class backend_visitor : public ir_visitor {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index b524d4a..12b2ebe 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -171,8 +171,6 @@ public:
    src_reg src[3];
 
    bool saturate;
-   bool predicate_inverse;
-   uint32_t predicate;
 
    int conditional_mod; /**< BRW_CONDITIONAL_* */
 
-- 
1.7.10.4



More information about the mesa-dev mailing list