nir: save IO semantics in lowered IO intrinsics
[mesa.git] / src / compiler / nir / nir_gs_count_vertices.c
index 3c1bd2a59bd97d4e8947292ce204abf00313be28..06b9cdf73763e8d72ad296a6f4b88cbcdb52bc77 100644 (file)
@@ -55,35 +55,33 @@ nir_gs_count_vertices(const nir_shader *shader)
 {
    int count = -1;
 
-   nir_foreach_function(shader, function) {
+   nir_foreach_function(function, shader) {
       if (!function->impl)
          continue;
 
       /* set_vertex_count intrinsics only appear in predecessors of the
        * end block.  So we don't need to walk all of them.
        */
-      struct set_entry *entry;
       set_foreach(function->impl->end_block->predecessors, entry) {
          nir_block *block = (nir_block *) entry->key;
 
-         nir_foreach_instr_reverse(block, instr) {
+         nir_foreach_instr_reverse(instr, block) {
             nir_intrinsic_instr *intrin = as_set_vertex_count(instr);
             if (!intrin)
                continue;
 
-            nir_const_value *val = nir_src_as_const_value(intrin->src[0]);
             /* We've found a non-constant value.  Bail. */
-            if (!val)
+            if (!nir_src_is_const(intrin->src[0]))
                return -1;
 
             if (count == -1)
-               count = val->i32[0];
+               count = nir_src_as_int(intrin->src[0]);
 
             /* We've found contradictory set_vertex_count intrinsics.
              * This can happen if there are early-returns in main() and
              * different paths emit different numbers of vertices.
              */
-            if (count != val->i32[0])
+            if (count != nir_src_as_int(intrin->src[0]))
                return -1;
          }
       }