Mesa (master): nir/opt_loop_unroll: fix is_access_out_of_bounds with vectors

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 9 13:00:51 UTC 2020


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

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Mon Aug 17 13:19:43 2020 +0100

nir/opt_loop_unroll: fix is_access_out_of_bounds with vectors

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsquueze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6347>

---

 src/compiler/nir/nir_opt_loop_unroll.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_opt_loop_unroll.c b/src/compiler/nir/nir_opt_loop_unroll.c
index c5e7b8c9b51..7dc27a10387 100644
--- a/src/compiler/nir/nir_opt_loop_unroll.c
+++ b/src/compiler/nir/nir_opt_loop_unroll.c
@@ -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;



More information about the mesa-commit mailing list