Our code currently only remove dead writes to vars for each block, but doesn't tackle cases that involve multiple blocks. This series will add a pass that use an iterative data-flow analysis to cover those cases. Commit message for patch 6 has a detailed example.
I'm working on a subsequent series for adding global capabilities to copy propagation. While those optimizations can be done locally together (as we currently do), the way we iterate the blocks for data-flow analysis is different (dead write uses backward, copy propagation uses forward), so it helps keeping them separate. The motivation for this series (and the upcoming copy propagation) work is to improve our generated code when we move other memory accesses (e.g. SSBOs) to use derefs. Patches 1-4 are small and are worth regardless the series -- I have other series locally that use some of those. So I intend to land them earlier as they get reviewed. Caio Marcelo de Oliveira Filho (9): util/dynarray: add a clone function nir: Export deref comparison functions nir: Skip common instructions when comparing deref paths nir: Give end_block its own index nir: Add a local dead write vars removal pass nir: Make dead_write_vars pass global intel/nir: Use the new dead write vars pass freedreno/ir3: Use the new dead write vars pass nir: Remove handling of dead writes from copy_prop_vars src/compiler/Makefile.sources | 1 + src/compiler/nir/meson.build | 1 + src/compiler/nir/nir.c | 2 +- src/compiler/nir/nir.h | 2 + src/compiler/nir/nir_deref.c | 112 +++ src/compiler/nir/nir_deref.h | 10 + src/compiler/nir/nir_opt_copy_prop_vars.c | 208 +----- src/compiler/nir/nir_opt_dead_write_vars.c | 761 ++++++++++++++++++++ src/gallium/drivers/freedreno/ir3/ir3_nir.c | 1 + src/intel/compiler/brw_nir.c | 1 + src/util/u_dynarray.h | 9 + 11 files changed, 913 insertions(+), 195 deletions(-) create mode 100644 src/compiler/nir/nir_opt_dead_write_vars.c -- 2.18.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev