Module: Mesa
Branch: main
Commit: 4382bd8a3438638bc69453513a835c52c8890108
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4382bd8a3438638bc69453513a835c52c8890108

Author: Timothy Arceri <[email protected]>
Date:   Wed Oct 25 10:58:09 2023 +1100

nir: simplify nir_build_write_masked_store()

Suggested-by: Alyssa Rosenzweig <[email protected]>
Acked-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25860>

---

 src/compiler/nir/nir_builder.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 0084d7e0d9d..475aac42c7c 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -1648,12 +1648,9 @@ nir_build_write_masked_store(nir_builder *b, 
nir_deref_instr *vec_deref,
    unsigned num_components = glsl_get_components(vec_deref->type);
    assert(num_components > 1 && num_components <= NIR_MAX_VEC_COMPONENTS);
 
-   nir_def *u = nir_undef(b, 1, value->bit_size);
-   nir_def *comps[NIR_MAX_VEC_COMPONENTS];
-   for (unsigned i = 0; i < num_components; i++)
-      comps[i] = (i == component) ? value : u;
-
-   nir_def *vec = nir_vec(b, comps, num_components);
+   nir_def *vec =
+      nir_vector_insert_imm(b, nir_undef(b, num_components, value->bit_size),
+                            value, component);
    nir_store_deref(b, vec_deref, vec, (1u << component));
 }
 

Reply via email to