nir: Add a nir_ssa_def_all_uses_are_fsat() helper

Extracted from nir_lower_to_source_mods, this is useful for back-ends
which don't want to rely on NIR source and destination modifiers.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25000>
This commit is contained in:
Faith Ekstrand
2023-04-28 18:44:55 -05:00
committed by Marge Bot
parent 28ebe62af2
commit 0680330cf7
2 changed files with 20 additions and 0 deletions
+19
View File
@@ -1636,6 +1636,25 @@ nir_def_components_read(const nir_def *def)
return read_mask;
}
bool
nir_def_all_uses_are_fsat(const nir_def *def)
{
nir_foreach_use(src, def) {
if (nir_src_is_if(src))
return false;
nir_instr *use = nir_src_parent_instr(src);
if (use->type != nir_instr_type_alu)
return false;
nir_alu_instr *alu = nir_instr_as_alu(use);
if (alu->op != nir_op_fsat)
return false;
}
return true;
}
nir_block *
nir_block_unstructured_next(nir_block *block)
{
+1
View File
@@ -4595,6 +4595,7 @@ void nir_def_rewrite_uses_after(nir_def *def, nir_def *new_ssa,
nir_component_mask_t nir_src_components_read(const nir_src *src);
nir_component_mask_t nir_def_components_read(const nir_def *def);
bool nir_def_all_uses_are_fsat(const nir_def *def);
static inline bool
nir_def_is_unused(nir_def *ssa)