nir/cf: handle phi nodes better in split_block_beginning()
authorConnor Abbott <cwabbott0@gmail.com>
Wed, 22 Jul 2015 02:54:23 +0000 (19:54 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 24 Aug 2015 20:31:42 +0000 (13:31 -0700)
Signed-off-by: Connor Abbott <connor.w.abbott@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/nir/nir_control_flow.c

index 205b60819d4569fe73c0a8ae1c48a4fac7a37ba1..b416a5813d36b581bbee49fd50c62e5c6b45929e 100644 (file)
@@ -210,6 +210,19 @@ split_block_beginning(nir_block *block)
       link_blocks(pred, new_block, NULL);
    }
 
+   /* Any phi nodes must stay part of the new block, or else their
+    * sourcse will be messed up. This will reverse the order of the phi's, but
+    * order shouldn't matter.
+    */
+   nir_foreach_instr_safe(block, instr) {
+      if (instr->type != nir_instr_type_phi)
+         break;
+
+      exec_node_remove(&instr->node);
+      instr->block = new_block;
+      exec_list_push_head(&new_block->instr_list, &instr->node);
+   }
+
    return new_block;
 }