nir: Use nir_src_rewrite_ssa

Where sensible.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22343>
This commit is contained in:
Alyssa Rosenzweig
2023-04-06 17:13:45 -04:00
committed by Marge Bot
parent e9e0956d62
commit e25c182993
2 changed files with 9 additions and 24 deletions

View File

@@ -1743,10 +1743,7 @@ nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_ssa_def *new_ssa)
{
assert(def != new_ssa);
nir_foreach_use_including_if_safe(use_src, def) {
if (use_src->is_if)
nir_if_rewrite_condition_ssa(use_src->parent_if, use_src, new_ssa);
else
nir_instr_rewrite_src_ssa(use_src->parent_instr, use_src, new_ssa);
nir_src_rewrite_ssa(use_src, new_ssa);
}
}
@@ -1803,17 +1800,18 @@ nir_ssa_def_rewrite_uses_after(nir_ssa_def *def, nir_ssa_def *new_ssa,
return;
nir_foreach_use_including_if_safe(use_src, def) {
if (use_src->is_if) {
nir_if_rewrite_condition_ssa(use_src->parent_if, use_src, new_ssa);
} else {
if (!use_src->is_if) {
assert(use_src->parent_instr != def->parent_instr);
/* Since def already dominates all of its uses, the only way a use can
* not be dominated by after_me is if it is between def and after_me in
* the instruction list.
*/
if (!is_instr_between(def->parent_instr, after_me, use_src->parent_instr))
nir_instr_rewrite_src_ssa(use_src->parent_instr, use_src, new_ssa);
if (is_instr_between(def->parent_instr, after_me, use_src->parent_instr))
continue;
}
nir_src_rewrite_ssa(use_src, new_ssa);
}
}

View File

@@ -117,18 +117,7 @@ copy_propagate(nir_src *src, nir_alu_instr *copy)
if (!is_swizzleless_move(copy))
return false;
nir_instr_rewrite_src_ssa(src->parent_instr, src, copy->src[0].src.ssa);
return true;
}
static bool
copy_propagate_if(nir_src *src, nir_alu_instr *copy)
{
if (!is_swizzleless_move(copy))
return false;
nir_if_rewrite_condition_ssa(src->parent_if, src, copy->src[0].src.ssa);
nir_src_rewrite_ssa(src, copy->src[0].src.ssa);
return true;
}
@@ -147,9 +136,7 @@ copy_prop_instr(nir_function_impl *impl, nir_instr *instr)
bool progress = false;
nir_foreach_use_including_if_safe(src, &mov->dest.dest.ssa) {
if (src->is_if)
progress |= copy_propagate_if(src, mov);
else if (src->parent_instr->type == nir_instr_type_alu)
if (!src->is_if && src->parent_instr->type == nir_instr_type_alu)
progress |= copy_propagate_alu(impl, container_of(src, nir_alu_src, src), mov);
else
progress |= copy_propagate(src, mov);