Module: Mesa
Branch: master
Commit: eb8fefe0904909729bac37c32e738223653cbb58
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb8fefe0904909729bac37c32e738223653cbb58

Author: Dave Airlie <[email protected]>
Date:   Wed Apr  3 12:20:02 2019 +1000

nir: use proper array sizing define for vectors

If we increase the vector size in the future it would be good
to not have to fix these up, this should change nothing at present.

Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>

---

 src/compiler/nir/nir_opt_copy_propagate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_opt_copy_propagate.c 
b/src/compiler/nir/nir_opt_copy_propagate.c
index 10b81c0a684..909839ad962 100644
--- a/src/compiler/nir/nir_opt_copy_propagate.c
+++ b/src/compiler/nir/nir_opt_copy_propagate.c
@@ -142,17 +142,17 @@ copy_prop_alu_src(nir_alu_instr *parent_alu_instr, 
unsigned index)
       return false;
 
    nir_ssa_def *def;
-   unsigned new_swizzle[4] = {0, 0, 0, 0};
+   unsigned new_swizzle[NIR_MAX_VEC_COMPONENTS] = {0, 0, 0, 0};
 
    if (alu_instr->op == nir_op_fmov ||
        alu_instr->op == nir_op_imov) {
-      for (unsigned i = 0; i < 4; i++)
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
          new_swizzle[i] = alu_instr->src[0].swizzle[src->swizzle[i]];
       def = alu_instr->src[0].src.ssa;
    } else {
       def = NULL;
 
-      for (unsigned i = 0; i < 4; i++) {
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {
          if (!nir_alu_instr_channel_used(parent_alu_instr, index, i))
             continue;
 
@@ -167,7 +167,7 @@ copy_prop_alu_src(nir_alu_instr *parent_alu_instr, unsigned 
index)
       }
    }
 
-   for (unsigned i = 0; i < 4; i++)
+   for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
       src->swizzle[i] = new_swizzle[i];
 
    nir_instr_rewrite_src(&parent_alu_instr->instr, &src->src,

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to