nir: Use a switch in nir_inline_function_impl
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 20 Aug 2020 19:42:30 +0000 (14:42 -0500)
committerMarge Bot <eric+marge@anholt.net>
Sat, 29 Aug 2020 18:32:46 +0000 (18:32 +0000)
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6411>

src/compiler/nir/nir_inline_functions.c

index d7144b39a8d6744f0d6ac7a1e18615a53f8dff54..03a26e0dbf3e79b21832157d1bcc0bc2c8e0a891 100644 (file)
@@ -44,27 +44,33 @@ void nir_inline_function_impl(struct nir_builder *b,
 
    nir_foreach_block(block, copy) {
       nir_foreach_instr_safe(instr, block) {
-         /* Returns have to be lowered for this to work */
-         assert(instr->type != nir_instr_type_jump ||
-                nir_instr_as_jump(instr)->type != nir_jump_return);
-
-         if (instr->type != nir_instr_type_intrinsic)
-            continue;
-
-         nir_intrinsic_instr *load = nir_instr_as_intrinsic(instr);
-         if (load->intrinsic != nir_intrinsic_load_param)
-            continue;
-
-         unsigned param_idx = nir_intrinsic_param_idx(load);
-         assert(param_idx < impl->function->num_params);
-         assert(load->dest.is_ssa);
-         nir_ssa_def_rewrite_uses(&load->dest.ssa,
-                                  nir_src_for_ssa(params[param_idx]));
-
-         /* Remove any left-over load_param intrinsics because they're soon
-          * to be in another function and therefore no longer valid.
-          */
-         nir_instr_remove(&load->instr);
+         switch (instr->type) {
+         case nir_instr_type_intrinsic: {
+            nir_intrinsic_instr *load = nir_instr_as_intrinsic(instr);
+            if (load->intrinsic != nir_intrinsic_load_param)
+               break;
+
+            unsigned param_idx = nir_intrinsic_param_idx(load);
+            assert(param_idx < impl->function->num_params);
+            assert(load->dest.is_ssa);
+            nir_ssa_def_rewrite_uses(&load->dest.ssa,
+                                     nir_src_for_ssa(params[param_idx]));
+
+            /* Remove any left-over load_param intrinsics because they're soon
+             * to be in another function and therefore no longer valid.
+             */
+            nir_instr_remove(&load->instr);
+            break;
+         }
+
+         case nir_instr_type_jump:
+            /* Returns have to be lowered for this to work */
+            assert(nir_instr_as_jump(instr)->type != nir_jump_return);
+            break;
+
+         default:
+            break;
+         }
       }
    }