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

Author: Connor Abbott <[email protected]>
Date:   Tue Jul 30 11:05:22 2019 +0200

nir/find_array_copies: Use correct parent array length

instr->type is the type of the array element, not the type of the array
being dereferenced. Rather than fishing out the parent type, just use
parent->num_children which should be the length plus 1. While we're here
add another assert for the issue fixed by the previous commit.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111251
Fixes: 156306e5e62 ("nir/find_array_copies: Handle wildcards and overlapping 
copies")
Reviewed-by: Jason Ekstrand <[email protected]>

---

 src/compiler/nir/nir_opt_find_array_copies.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_opt_find_array_copies.c 
b/src/compiler/nir/nir_opt_find_array_copies.c
index 28f77335d99..63609715c3a 100644
--- a/src/compiler/nir/nir_opt_find_array_copies.c
+++ b/src/compiler/nir/nir_opt_find_array_copies.c
@@ -100,14 +100,15 @@ node_for_deref(nir_deref_instr *instr, struct match_node 
*parent,
    }
 
    case nir_deref_type_array_wildcard:
-      idx = glsl_get_length(instr->type);
+      idx = parent->num_children - 1;
       break;
 
    case nir_deref_type_array:
       if (nir_src_is_const(instr->arr.index)) {
          idx = nir_src_as_uint(instr->arr.index);
+         assert(idx < parent->num_children - 1);
       } else {
-         idx = glsl_get_length(instr->type);
+         idx = parent->num_children - 1;
       }
       break;
 

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

Reply via email to