This series contains improvements to GLSL copy (and constant) propagation. In most cases the numbers do not change (at least in the Intel configurations I've tested) because the NIR passes pick up the slack.
It all started with the patches "don't let an 'if' ...", which are about cases like b = a; if (...) { c = b * 2; // This 'b' gets replaced with 'a'. b = 1; } else { c = b * 3; // This 'b' doesn't get replaced with 'a'. } where the then-branch and the else-branch get treated differently for no particular reason. This happens because the "kill" in the then-branch was causing 'b' to not be available in the else-branch. These are relatively simple fixes in constant and copy propagation, but in opt_copy_propagation_elements.cpp, we need to provide a proper way to "clone" the data structures used there. To achieve that I've ended up proposing a change to those data structures. The first three patches are less intrusive, and could be considered independently. Then the next five patches change how opt_copy_propagation_elements.cpp work, ending with the "don't let an 'if' ..." for it. The last two patches teach the opt_copy_propagation_elements.cpp how to handle whole variables and remove opt_copy_propagation.cpp. I'm marking those as RFC since I just made them work (hopefully) correctly and didn't care much about performance. There are some low hanging fruits but I'll invest only if there's interest. Because NIR passes pick up most of the slack, another reasonable approach could be just stick some comments in the GLSL passes about the "if/else" case. So I don't mind doing that either. Caio Marcelo de Oliveira Filho (10): glsl: don't let an 'if' then-branch kill const propagation for else-branch glsl: do second pass of const propagation in loops glsl: don't let an 'if' then-branch kill copy propagation for else-branch glsl: separate copy propagation state util/set: add a clone function util/set: helper to remove entry by key glsl: change opt_copy_propagation_elements data structures glsl: don't let an 'if' then-branch kill copy propagation (elements) for else-branch glsl: teach copy_propagation_elements to deal with whole variables glsl: use only copy_propagation_elements src/compiler/Makefile.sources | 1 - src/compiler/glsl/glsl_parser_extras.cpp | 1 - src/compiler/glsl/ir_optimization.h | 1 - src/compiler/glsl/meson.build | 1 - .../glsl/opt_constant_propagation.cpp | 72 ++- src/compiler/glsl/opt_copy_propagation.cpp | 369 ------------- .../glsl/opt_copy_propagation_elements.cpp | 521 +++++++++++------- src/compiler/glsl/test_optpass.cpp | 2 - src/util/set.c | 32 ++ src/util/set.h | 5 + 10 files changed, 403 insertions(+), 602 deletions(-) delete mode 100644 src/compiler/glsl/opt_copy_propagation.cpp -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev