i965/fs: Don't use if_block/else_block in SEL peephole.
authorMatt Turner <mattst88@gmail.com>
Tue, 11 Nov 2014 06:02:38 +0000 (22:02 -0800)
committerMatt Turner <mattst88@gmail.com>
Tue, 11 Nov 2014 17:41:06 +0000 (09:41 -0800)
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp

index c3bfd00e70dc25b147c023c581f90256b2aa3d2e..f18589cbe991870c68b8c271638bedf93b951867 100644 (file)
@@ -132,16 +132,21 @@ fs_visitor::opt_peephole_sel()
       if (if_inst->opcode != BRW_OPCODE_IF)
          continue;
 
-      if (!block->else_block)
-         continue;
-
-      assert(block->else_block->end()->opcode == BRW_OPCODE_ELSE);
-
       fs_inst *else_mov[MAX_MOVS] = { NULL };
       fs_inst *then_mov[MAX_MOVS] = { NULL };
 
       bblock_t *then_block = block->next();
-      bblock_t *else_block = block->else_block->next();
+      bblock_t *else_block = NULL;
+      foreach_list_typed(bblock_link, child, link, &block->children) {
+         if (child->block != then_block) {
+            if (child->block->prev()->end()->opcode == BRW_OPCODE_ELSE) {
+               else_block = child->block;
+            }
+            break;
+         }
+      }
+      if (else_block == NULL)
+         continue;
 
       int movs = count_movs_from_if(then_mov, else_mov, then_block, else_block);