OSDN Git Service

i965/fs: Add a helper function for checking for partial register updates.
authorEric Anholt <eric@anholt.net>
Mon, 4 Jun 2012 15:59:00 +0000 (08:59 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 12 Apr 2013 23:32:12 +0000 (16:32 -0700)
These checks were all over, and every time I wrote one I had to try to
decide again what the cases were for partial updates.

v2: Fix inadvertent reladdr check removal.
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
src/mesa/drivers/dri/i965/brw_fs_cse.cpp
src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp

index c55c910..f9a50b1 100644 (file)
@@ -711,6 +711,22 @@ fs_visitor::pop_force_sechalf()
 }
 
 /**
+ * Returns true if the instruction has a flag that means it won't
+ * update an entire destination register.
+ *
+ * For example, dead code elimination and live variable analysis want to know
+ * when a write to a variable screens off any preceding values that were in
+ * it.
+ */
+bool
+fs_inst::is_partial_write()
+{
+   return (this->predicate ||
+           this->force_uncompressed ||
+           this->force_sechalf);
+}
+
+/**
  * Returns how many MRFs an FS opcode will write over.
  *
  * Note that this is not the 0 or 1 implied writes in an actual gen
@@ -2065,22 +2081,14 @@ fs_visitor::compute_to_mrf()
             * into a compute-to-MRF.
             */
 
-           /* If it's predicated, it (probably) didn't populate all
-            * the channels.  We might be able to rewrite everything
+           /* 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.
             */
-           if (scan_inst->predicate)
+           if (scan_inst->is_partial_write())
               break;
 
-           /* If it's half of register setup and not the same half as
-            * our MOV we're trying to remove, bail for now.
-            */
-           if (scan_inst->force_uncompressed != inst->force_uncompressed ||
-               scan_inst->force_sechalf != inst->force_sechalf) {
-              break;
-           }
-
             /* Things returning more than one register would need us to
              * understand coalescing out more than one MOV at a time.
              */
@@ -2662,9 +2670,7 @@ fs_visitor::get_instruction_generating_reg(fs_inst *start,
                                           fs_reg reg)
 {
    if (end == start ||
-       end->predicate ||
-       end->force_uncompressed ||
-       end->force_sechalf ||
+       end->is_partial_write() ||
        reg.reladdr ||
        !reg.equals(end->dst)) {
       return NULL;
index 115a878..bcaa485 100644 (file)
@@ -179,6 +179,7 @@ public:
    bool is_math();
    bool is_control_flow();
    bool is_send_from_grf();
+   bool is_partial_write();
 
    fs_reg dst;
    fs_reg src[3];
index 36df759..234f8bd 100644 (file)
@@ -414,9 +414,7 @@ fs_visitor::opt_copy_propagate_local(void *mem_ctx, bblock_t *block,
            inst->src[0].file == IMM) &&
          inst->src[0].type == inst->dst.type &&
          !inst->saturate &&
-         !inst->predicate &&
-         !inst->force_uncompressed &&
-         !inst->force_sechalf) {
+         !inst->is_partial_write()) {
         acp_entry *entry = ralloc(mem_ctx, acp_entry);
         entry->dst = inst->dst;
         entry->src = inst->src[0];
index 2a8fd0b..b5c2200 100644 (file)
@@ -97,8 +97,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->predicate &&
-          !inst->force_uncompressed && !inst->force_sechalf &&
+      if (is_expression(inst) && !inst->is_partial_write() &&
           !inst->conditional_mod)
       {
         bool found = false;
index ca60aa2..fdcfac6 100644 (file)
@@ -78,9 +78,7 @@ fs_live_variables::setup_def_use()
          */
         if (inst->dst.file == GRF &&
             inst->regs_written == v->virtual_grf_sizes[inst->dst.reg] &&
-            !inst->predicate &&
-            !inst->force_uncompressed &&
-            !inst->force_sechalf) {
+            !inst->is_partial_write()) {
            int reg = inst->dst.reg;
             if (!BITSET_TEST(bd[b].use, reg))
                BITSET_SET(bd[b].def, reg);