nir/cf: add remove_phi_src() helper
authorConnor Abbott <cwabbott0@gmail.com>
Wed, 22 Jul 2015 02:54:21 +0000 (19:54 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 24 Aug 2015 20:31:41 +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 bb94652757b763109728db7792ba3bda9bb4f0cb..bf25813e8f1f6b20d11fa312f4117fe7c7855e5e 100644 (file)
@@ -373,6 +373,23 @@ nir_handle_add_jump(nir_block *block)
    }
 }
 
+static void
+remove_phi_src(nir_block *block, nir_block *pred)
+{
+   nir_foreach_instr(block, instr) {
+      if (instr->type != nir_instr_type_phi)
+         break;
+
+      nir_phi_instr *phi = nir_instr_as_phi(instr);
+      nir_foreach_phi_src_safe(phi, src) {
+         if (src->pred == pred) {
+            list_del(&src->src.use_link);
+            exec_node_remove(&src->node);
+         }
+      }
+   }
+}
+
 void
 nir_handle_remove_jump(nir_block *block, nir_jump_type type)
 {