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 c55c91062879344f7e387ae18b3eaea0b780af14..f9a50b1c18782aed6204385961c66417b76c7ff8 100644 (file)
@@ -710,6 +710,22 @@ fs_visitor::pop_force_sechalf()
    assert(force_sechalf_stack >= 0);
 }
 
+/**
+ * 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.
  *
@@ -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 115a878d99ac16dceda78cb8223cd80c0f112960..bcaa485781e80180f2a0f90ae9ed2f4e0969e001 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 36df7599e2829ac358d89db59be5d65675d68952..234f8bd3870c988094ee207c96ca5e9c67265f21 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 2a8fd0be2e7d6a4e79d5d6659d6c51beb5cfde04..b5c220090cf792ab48cc44a5c2f2cb2fe178b9fe 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 ca60aa235fe059161d1b399816afd43cfb865893..fdcfac611940de6a6369603b8fb88bfffee8b265 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);