The var splitting pass can rearrange the variables as long as their
position in memory doesn't matter. For block-arranged variables,
or things like memcpys or casts, the layout matters, but atomics
don't imply anything about the layout of the overall variable, so
don't treat them as "complex" for this use case.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23173>
typedef enum {
nir_deref_instr_has_complex_use_allow_memcpy_src = (1 << 0),
nir_deref_instr_has_complex_use_allow_memcpy_dst = (1 << 1),
+ nir_deref_instr_has_complex_use_allow_atomics = (1 << 2),
} nir_deref_instr_has_complex_use_options;
bool nir_deref_instr_has_complex_use(nir_deref_instr *instr,
continue;
return true;
+ case nir_intrinsic_deref_atomic:
+ case nir_intrinsic_deref_atomic_swap:
+ if (opts & nir_deref_instr_has_complex_use_allow_atomics)
+ continue;
+ return true;
+
default:
return true;
}
* nir_deref_instr_has_complex_use is recursive.
*/
if (deref->deref_type == nir_deref_type_var &&
- nir_deref_instr_has_complex_use(deref, 0))
+ nir_deref_instr_has_complex_use(deref,
+ nir_deref_instr_has_complex_use_allow_atomics))
_mesa_set_add(complex_vars, deref->var);
}
}
if (!(deref->var->data.mode & modes))
return;
- if (!nir_deref_instr_has_complex_use(deref, 0))
+ if (!nir_deref_instr_has_complex_use(deref, nir_deref_instr_has_complex_use_allow_atomics))
return;
struct vec_var_usage *usage =