Module: Mesa Branch: master Commit: 41125bff4ff2e79895975f76601a6c7a18029a3d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=41125bff4ff2e79895975f76601a6c7a18029a3d
Author: Rhys Perry <[email protected]> Date: Fri Jan 29 14:32:50 2021 +0000 nir/copy_prop: remove unused copies These were hurting performance of other passes. Compile-time (overall): Difference at 95.0% confidence -5496.3 +/- 219.752 -4.11912% +/- 0.160285% (Student's t, pooled s = 259.538) Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8784> --- src/compiler/nir/nir_opt_copy_propagate.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_opt_copy_propagate.c b/src/compiler/nir/nir_opt_copy_propagate.c index be9bce3ef2e..52c8acec306 100644 --- a/src/compiler/nir/nir_opt_copy_propagate.c +++ b/src/compiler/nir/nir_opt_copy_propagate.c @@ -99,7 +99,8 @@ copy_prop_src(nir_src *src, nir_instr *parent_instr, nir_if *parent_if, { assert(src->is_ssa); - nir_instr *src_instr = src->ssa->parent_instr; + nir_ssa_def *original_ssa = src->ssa; + nir_instr *src_instr = original_ssa->parent_instr; nir_ssa_def *copy_def; if (src_instr->type == nir_instr_type_alu) { nir_alu_instr *alu_instr = nir_instr_as_alu(src_instr); @@ -121,6 +122,9 @@ copy_prop_src(nir_src *src, nir_instr *parent_instr, nir_if *parent_if, nir_if_rewrite_condition(parent_if, nir_src_for_ssa(copy_def)); } + if (nir_ssa_def_is_unused(original_ssa)) + nir_instr_remove(src_instr); + return true; } @@ -130,7 +134,8 @@ copy_prop_alu_src(nir_alu_instr *parent_alu_instr, unsigned index) nir_alu_src *src = &parent_alu_instr->src[index]; assert(src->src.is_ssa); - nir_instr *src_instr = src->src.ssa->parent_instr; + nir_ssa_def *original_ssa = src->src.ssa; + nir_instr *src_instr = original_ssa->parent_instr; if (src_instr->type != nir_instr_type_alu) return false; @@ -169,6 +174,9 @@ copy_prop_alu_src(nir_alu_instr *parent_alu_instr, unsigned index) nir_instr_rewrite_src(&parent_alu_instr->instr, &src->src, nir_src_for_ssa(def)); + if (nir_ssa_def_is_unused(original_ssa)) + nir_instr_remove(src_instr); + return true; } _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
