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

Author: Lionel Landwerlin <[email protected]>
Date:   Tue Mar  7 13:08:36 2023 +0200

intel/fs: fix nir_opt_peephole_ffma max vec assumption

There can be larger vec than vec4.

Signed-off-by: Lionel Landwerlin <[email protected]>
Cc: mesa-stable
Reviewed-by: Marcin Ĺšlusarz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21782>

---

 src/intel/compiler/brw_nir_opt_peephole_ffma.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/intel/compiler/brw_nir_opt_peephole_ffma.c 
b/src/intel/compiler/brw_nir_opt_peephole_ffma.c
index ce8d6376055..2a39a22c5dc 100644
--- a/src/intel/compiler/brw_nir_opt_peephole_ffma.c
+++ b/src/intel/compiler/brw_nir_opt_peephole_ffma.c
@@ -68,9 +68,9 @@ are_all_uses_fadd(nir_ssa_def *def)
 
 static nir_alu_instr *
 get_mul_for_src(nir_alu_src *src, unsigned num_components,
-                uint8_t swizzle[4], bool *negate, bool *abs)
+                uint8_t *swizzle, bool *negate, bool *abs)
 {
-   uint8_t swizzle_tmp[4];
+   uint8_t swizzle_tmp[NIR_MAX_VEC_COMPONENTS];
    assert(src->src.is_ssa && !src->abs && !src->negate);
 
    nir_instr *instr = src->src.ssa->parent_instr;
@@ -133,7 +133,7 @@ get_mul_for_src(nir_alu_src *src, unsigned num_components,
     *   Expected output swizzle = zyxx
     *   If we reuse swizzle in the loop, then output swizzle would be zyzz.
     */
-   memcpy(swizzle_tmp, swizzle, 4*sizeof(uint8_t));
+   memcpy(swizzle_tmp, swizzle, NIR_MAX_VEC_COMPONENTS*sizeof(uint8_t));
    for (int i = 0; i < num_components; i++)
       swizzle[i] = swizzle_tmp[src->swizzle[i]];
 
@@ -189,10 +189,10 @@ brw_nir_opt_peephole_ffma_instr(nir_builder *b,
       return false;
 
    nir_alu_instr *mul;
-   uint8_t add_mul_src, swizzle[4];
+   uint8_t add_mul_src, swizzle[NIR_MAX_VEC_COMPONENTS];
    bool negate, abs;
    for (add_mul_src = 0; add_mul_src < 2; add_mul_src++) {
-      for (unsigned i = 0; i < 4; i++)
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
          swizzle[i] = i;
 
       negate = false;

Reply via email to