pan/mdg: Limit int64 vectorization
authorIcecream95 <ixn@disroot.org>
Mon, 28 Dec 2020 11:53:27 +0000 (00:53 +1300)
committerMarge Bot <eric+marge@anholt.net>
Mon, 18 Jan 2021 20:49:45 +0000 (20:49 +0000)
Previously, nir_opt_vectorize was sometimes vectorizing 64-bit
load_const instructions to vec4.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8358>

src/panfrost/midgard/midgard_compile.c

index 64123ea..ec219df 100644 (file)
@@ -229,6 +229,29 @@ mdg_is_64(const nir_instr *instr, const void *_unused)
         }
 }
 
+/* Only vectorize int64 up to vec2 */
+static bool
+midgard_vectorize_filter(const nir_instr *instr, void *data)
+{
+        if (instr->type != nir_instr_type_alu)
+                return true;
+
+        const nir_alu_instr *alu = nir_instr_as_alu(instr);
+
+        unsigned num_components = alu->dest.dest.ssa.num_components;
+
+        int src_bit_size = nir_src_bit_size(alu->src[0].src);
+        int dst_bit_size = nir_dest_bit_size(alu->dest.dest);
+
+        if (src_bit_size == 64 || dst_bit_size == 64) {
+                if (num_components > 1)
+                        return false;
+        }
+
+        return true;
+}
+
+
 /* Flushes undefined values to zero */
 
 static void
@@ -308,7 +331,8 @@ optimise_nir(nir_shader *nir, unsigned quirks, bool is_blend)
                          nir_var_shader_out |
                          nir_var_function_temp);
 
-                NIR_PASS(progress, nir, nir_opt_vectorize, NULL, NULL);
+                NIR_PASS(progress, nir, nir_opt_vectorize,
+                         midgard_vectorize_filter, NULL);
         } while (progress);
 
         NIR_PASS_V(nir, nir_lower_alu_to_scalar, mdg_is_64, NULL);