nir: don't move accesses across make visible/available barriers

Otherwise, the barrier would no longer affect the access.

nir_opt_dead_write_vars should be fine, since it's removing stores, not
moving them.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36080>
This commit is contained in:
Rhys Perry 2025-07-08 17:29:18 +01:00 committed by Marge Bot
parent d54f2ca84f
commit ae6e39a8f5
3 changed files with 5 additions and 5 deletions

View file

@ -311,7 +311,7 @@ combine_stores_block(struct combine_stores_state *state, nir_block *block)
break;
case nir_intrinsic_barrier:
if (nir_intrinsic_memory_semantics(intrin) & NIR_MEMORY_RELEASE) {
if (nir_intrinsic_memory_semantics(intrin) & (NIR_MEMORY_RELEASE | NIR_MEMORY_MAKE_AVAILABLE)) {
combine_stores_with_modes(state,
nir_intrinsic_memory_modes(intrin));
}

View file

@ -185,7 +185,7 @@ gather_vars_written(struct copy_prop_var_state *state,
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
switch (intrin->intrinsic) {
case nir_intrinsic_barrier:
if (nir_intrinsic_memory_semantics(intrin) & NIR_MEMORY_ACQUIRE)
if (nir_intrinsic_memory_semantics(intrin) & (NIR_MEMORY_ACQUIRE | NIR_MEMORY_MAKE_VISIBLE))
written->modes |= nir_intrinsic_memory_modes(intrin);
break;
@ -1027,7 +1027,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state,
if (debug)
dump_instr(instr);
if (nir_intrinsic_memory_semantics(intrin) & NIR_MEMORY_ACQUIRE)
if (nir_intrinsic_memory_semantics(intrin) & (NIR_MEMORY_ACQUIRE | NIR_MEMORY_MAKE_VISIBLE))
apply_barrier_for_modes(state, copies, nir_intrinsic_memory_modes(intrin));
break;

View file

@ -1539,8 +1539,8 @@ handle_barrier(struct vectorize_ctx *ctx, bool *progress, nir_function_impl *imp
nir_var_mem_shared |
nir_var_mem_global |
nir_var_mem_task_payload);
acquire = nir_intrinsic_memory_semantics(intrin) & NIR_MEMORY_ACQUIRE;
release = nir_intrinsic_memory_semantics(intrin) & NIR_MEMORY_RELEASE;
acquire = nir_intrinsic_memory_semantics(intrin) & (NIR_MEMORY_ACQUIRE | NIR_MEMORY_MAKE_VISIBLE);
release = nir_intrinsic_memory_semantics(intrin) & (NIR_MEMORY_RELEASE | NIR_MEMORY_MAKE_AVAILABLE);
switch (nir_intrinsic_memory_scope(intrin)) {
case SCOPE_INVOCATION:
/* a barier should never be required for correctness with these scopes */