intel/fs: fix nir_opt_peephole_ffma max vec assumption
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 7 Mar 2023 11:08:36 +0000 (13:08 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 14 Mar 2023 10:38:50 +0000 (10:38 +0000)
There can be larger vec than vec4.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Marcin Ĺšlusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21782>

src/intel/compiler/brw_nir_opt_peephole_ffma.c

index ce8d637..2a39a22 100644 (file)
@@ -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;