Mesa (master): nir: Two shared memory *blocks* may alias each other
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jan 27 22:46:26 UTC 2021
Module: Mesa
Branch: master
Commit: a9d230077f08955f97fddac84b4014d2131c8917
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9d230077f08955f97fddac84b4014d2131c8917
Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date: Tue Jul 7 17:38:03 2020 -0700
nir: Two shared memory *blocks* may alias each other
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8699>
---
src/compiler/nir/nir_deref.c | 12 ++++++++++++
src/compiler/nir/nir_remove_dead_variables.c | 12 ++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index 4735175b786..f406c87bbbf 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -492,6 +492,18 @@ nir_compare_deref_paths(nir_deref_path *a_path,
deref_path_contains_coherent_decoration(b_path))
return nir_derefs_may_alias_bit;
+ /* Per SPV_KHR_workgroup_memory_explicit_layout and GL_EXT_shared_memory_block,
+ * shared blocks alias each other.
+ */
+ if (a_path->path[0]->modes & nir_var_mem_shared &&
+ b_path->path[0]->modes & nir_var_mem_shared &&
+ (glsl_type_is_interface(a_path->path[0]->var->type) ||
+ glsl_type_is_interface(b_path->path[0]->var->type))) {
+ assert(glsl_type_is_interface(a_path->path[0]->var->type) &&
+ glsl_type_is_interface(b_path->path[0]->var->type));
+ return nir_derefs_may_alias_bit;
+ }
+
/* If we can chase the deref all the way back to the variable and
* they're not the same variable and at least one is not declared
* coherent, we know they can't possibly alias.
diff --git a/src/compiler/nir/nir_remove_dead_variables.c b/src/compiler/nir/nir_remove_dead_variables.c
index 19e56d077d4..0182c9889ed 100644
--- a/src/compiler/nir/nir_remove_dead_variables.c
+++ b/src/compiler/nir/nir_remove_dead_variables.c
@@ -71,8 +71,16 @@ add_var_use_deref(nir_deref_instr *deref, struct set *live)
* make them live. Only keep them if they are used by some intrinsic.
*/
if ((deref->var->data.mode & (nir_var_function_temp |
- nir_var_shader_temp |
- nir_var_mem_shared)) &&
+ nir_var_shader_temp)) &&
+ !deref_used_for_not_store(deref))
+ return;
+
+ /*
+ * Shared memory blocks (interface type) alias each other, so be
+ * conservative in that case.
+ */
+ if ((deref->var->data.mode & nir_var_mem_shared) &&
+ !glsl_type_is_interface(deref->var->type) &&
!deref_used_for_not_store(deref))
return;
More information about the mesa-commit
mailing list