From 73905c4d017d37e22a581dee5253340f062c559b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 22 Jul 2021 09:51:32 +0200 Subject: [PATCH] nir/opt_shrink_vectors: don't shrink vectors used by intrinsics Store intrinsics shrink the sources by creating a new vecN. Other intrinsics cannot shrink their sources. Reviewed-by: Emma Anholt Part-of: --- src/compiler/nir/nir_opt_shrink_vectors.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compiler/nir/nir_opt_shrink_vectors.c b/src/compiler/nir/nir_opt_shrink_vectors.c index d64a33f..6aa4bd5 100644 --- a/src/compiler/nir/nir_opt_shrink_vectors.c +++ b/src/compiler/nir/nir_opt_shrink_vectors.c @@ -49,6 +49,12 @@ shrink_dest_to_read_mask(nir_ssa_def *def) if (def->num_components == 1) return false; + /* don't remove any channels if used by an intrinsic */ + nir_foreach_use(use_src, def) { + if (use_src->parent_instr->type == nir_instr_type_intrinsic) + return false; + } + unsigned mask = nir_ssa_def_components_read(def); int last_bit = util_last_bit(mask); @@ -82,6 +88,12 @@ opt_shrink_vectors_alu(nir_builder *b, nir_alu_instr *instr) case nir_op_vec4: case nir_op_vec3: case nir_op_vec2: { + /* don't remove any channels if used by an intrinsic */ + nir_foreach_use(use_src, def) { + if (use_src->parent_instr->type == nir_instr_type_intrinsic) + return false; + } + unsigned mask = nir_ssa_def_components_read(def); /* If nothing was read, leave it up to DCE. */ -- 2.7.4