nir/algebraic: mark some optimizations with fsat(NaN) as inexact
[mesa.git] / src / compiler / nir / nir_gs_count_vertices.c
index 9e7c4a11c12d5992222bf63409f9136d3e15ee53..06b9cdf73763e8d72ad296a6f4b88cbcdb52bc77 100644 (file)
@@ -55,14 +55,13 @@ 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;
 
@@ -71,19 +70,18 @@ nir_gs_count_vertices(const nir_shader *shader)
             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;
          }
       }