nir/from_ssa: Ignore undef sources
Is a phi source is an undef, there's no point in copying it or really
caring about it at all. We would just end up inserting a mov from an
undef to a register. Instead, treat phi sources which point to an undef
as if the phi source doesn't exist.
This also prevents them from being included in phi webs which should
reduce the overall interference seen in the shader. Currently, if two
phis share an undef, their phi webs are consdiered to interfere. By
ignoring undefs we can get rid of this false interference and reduce the
size of phi webs. Reducing the number of things being copied by the
parallel copy instructions should also free up the paralle copy
algorithm and reduce the over-all churn of movs.
Shader-db results on Haswell:
total instructions in shared programs: 8156608 -> 8155406 (-0.01%)
instructions in affected programs: 164838 -> 163636 (-0.73%)
Shader-db results on Skylake:
total instructions in shared programs: 18227370 -> 18227359 (<.01%)
instructions in affected programs: 519 -> 508 (-2.12%)
helped: 6
HURT: 0
Shader-db results on Tigerlake:
total instructions in shared programs: 21167987 -> 21168025 (<.01%)
instructions in affected programs: 23701 -> 23739 (0.16%)
helped: 21
HURT: 27
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16817>
This commit is contained in:
committed by
Marge Bot
parent
c5c90e6ea4
commit
25dcb8d201
@@ -408,6 +408,9 @@ isolate_phi_nodes_block(nir_shader *shader, nir_block *block, void *dead_ctx)
|
||||
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
||||
assert(phi->dest.is_ssa);
|
||||
nir_foreach_phi_src(src, phi) {
|
||||
if (nir_src_is_undef(src->src))
|
||||
continue;
|
||||
|
||||
nir_parallel_copy_instr *pcopy =
|
||||
get_parallel_copy_at_end_of_block(src->pred);
|
||||
assert(pcopy);
|
||||
@@ -460,6 +463,9 @@ coalesce_phi_nodes_block(nir_block *block, struct from_ssa_state *state)
|
||||
|
||||
nir_foreach_phi_src(src, phi) {
|
||||
assert(src->src.is_ssa);
|
||||
if (nir_src_is_undef(src->src))
|
||||
continue;
|
||||
|
||||
merge_node *src_node = get_merge_node(src->src.ssa, state);
|
||||
if (src_node->set != dest_node->set)
|
||||
merge_merge_sets(dest_node->set, src_node->set);
|
||||
|
||||
Reference in New Issue
Block a user