nir/opt_loop_unroll: fix is_access_out_of_bounds with vectors
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 17 Aug 2020 12:19:43 +0000 (13:19 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 9 Sep 2020 12:34:47 +0000 (12:34 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsquueze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6347>

src/compiler/nir/nir_opt_loop_unroll.c

index c5e7b8c..7dc27a1 100644 (file)
@@ -592,14 +592,18 @@ is_access_out_of_bounds(nir_loop_terminator *term, nir_deref_instr *deref,
 
       nir_deref_instr *parent = nir_deref_instr_parent(d);
       assert(glsl_type_is_array(parent->type) ||
-             glsl_type_is_matrix(parent->type));
+             glsl_type_is_matrix(parent->type) ||
+             glsl_type_is_vector(parent->type));
 
       /* We have already unrolled the loop and the new one will be imbedded in
        * the innermost continue branch. So unless the array is greater than
        * the trip count any iteration over the loop will be an out of bounds
        * access of the array.
        */
-      return glsl_get_length(parent->type) <= trip_count;
+      unsigned length = glsl_type_is_vector(parent->type) ?
+                        glsl_get_vector_elements(parent->type) :
+                        glsl_get_length(parent->type);
+      return length <= trip_count;
    }
 
    return false;