i965/fs: Use a helper function for checking for flow control instructions.
authorEric Anholt <eric@anholt.net>
Tue, 5 Feb 2013 23:36:18 +0000 (15:36 -0800)
committerEric Anholt <eric@anholt.net>
Thu, 14 Feb 2013 01:47:06 +0000 (17:47 -0800)
In 2 of our checks, we were missing BREAK and CONTINUE.

NOTE: Candidate for the stable branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp

index 8e57eb0fd098407cede7ea1a4e90ca2466492c22..8dab4317c1024bafdb9df8ee2f66c95e3a457604 100644 (file)
@@ -327,6 +327,23 @@ fs_inst::is_math()
            opcode == SHADER_OPCODE_POW);
 }
 
+bool
+fs_inst::is_control_flow()
+{
+   switch (opcode) {
+   case BRW_OPCODE_DO:
+   case BRW_OPCODE_WHILE:
+   case BRW_OPCODE_IF:
+   case BRW_OPCODE_ELSE:
+   case BRW_OPCODE_ENDIF:
+   case BRW_OPCODE_BREAK:
+   case BRW_OPCODE_CONTINUE:
+      return true;
+   default:
+      return false;
+   }
+}
+
 bool
 fs_inst::is_send_from_grf()
 {
@@ -2070,16 +2087,12 @@ fs_visitor::compute_to_mrf()
            break;
         }
 
-        /* We don't handle flow control here.  Most computation of
+        /* We don't handle control flow here.  Most computation of
          * values that end up in MRFs are shortly before the MRF
          * write anyway.
          */
-        if (scan_inst->opcode == BRW_OPCODE_DO ||
-            scan_inst->opcode == BRW_OPCODE_WHILE ||
-            scan_inst->opcode == BRW_OPCODE_ELSE ||
-            scan_inst->opcode == BRW_OPCODE_ENDIF) {
+        if (scan_inst->is_control_flow() && scan_inst->opcode != BRW_OPCODE_IF)
            break;
-        }
 
         /* You can't read from an MRF, so if someone else reads our
          * MRF's source GRF that we wanted to rewrite, that stops us.
@@ -2163,16 +2176,8 @@ fs_visitor::remove_duplicate_mrf_writes()
    foreach_list_safe(node, &this->instructions) {
       fs_inst *inst = (fs_inst *)node;
 
-      switch (inst->opcode) {
-      case BRW_OPCODE_DO:
-      case BRW_OPCODE_WHILE:
-      case BRW_OPCODE_IF:
-      case BRW_OPCODE_ELSE:
-      case BRW_OPCODE_ENDIF:
+      if (inst->is_control_flow()) {
         memset(last_mrf_move, 0, sizeof(last_mrf_move));
-        continue;
-      default:
-        break;
       }
 
       if (inst->opcode == BRW_OPCODE_MOV &&
index d332502bde084c230365bb0489553777c02c0894..88fecb90494689be79dd5339826978fafed87967 100644 (file)
@@ -178,6 +178,7 @@ public:
    bool overwrites_reg(const fs_reg &reg);
    bool is_tex();
    bool is_math();
+   bool is_control_flow();
    bool is_send_from_grf();
 
    fs_reg dst;
index 3fbca6c4a13008fc412efdca64afabca37468439..c125928ee7d0a593908d1508a1356b14c432ebf4 100644 (file)
@@ -816,15 +816,8 @@ fs_visitor::schedule_instructions(bool post_reg_alloc)
         next_block_header = (fs_inst *)next_block_header->next;
 
         sched.add_inst(inst);
-        if (inst->opcode == BRW_OPCODE_IF ||
-            inst->opcode == BRW_OPCODE_ELSE ||
-            inst->opcode == BRW_OPCODE_ENDIF ||
-            inst->opcode == BRW_OPCODE_DO ||
-            inst->opcode == BRW_OPCODE_WHILE ||
-            inst->opcode == BRW_OPCODE_BREAK ||
-            inst->opcode == BRW_OPCODE_CONTINUE) {
+         if (inst->is_control_flow())
            break;
-        }
       }
       sched.calculate_deps();
       sched.schedule_instructions(next_block_header);