On Fri, May 8, 2015 at 11:15 PM, Jason Ekstrand <ja...@jlekstrand.net> wrote: > On Fri, May 8, 2015 at 10:03 PM, Connor Abbott <cwabbo...@gmail.com> wrote: >> This series implements a bunch of related optimizations that run at >> once as part of the same pass to eliminate control flow that is >> useless. This includes both unreachable code and useless loops, i.e. >> loops that don't compute a result used by the rest of the code. To do >> this, I needed to change some low-level things that change the behavior >> of nir_instr_remove() (see patch 2 for details), but I've tested the >> series on piglit and there are no regressions, and there are no >> shader-db changes either. > > I tried to get you shader-db results, but it crashes part-way through. > In particular, it looks like unigen heaven on high will crash it. > Either that or a couple of synmark shaders but I doubt those are the > culprets.
That patch seems to fix the crashes. Here's some shader-db results for you: Shader-db results for Broadwell: total FS instructions in shared programs: 7182550 -> 7182379 (-0.00%) FS instructions in affected programs: 3055 -> 2884 (-5.60%) helped: 29 HURT: 0 total NIR instructions in shared programs: 5413353 -> 5443233 (0.55%) NIR instructions in affected programs: 1453327 -> 1483207 (2.06%) helped: 4 HURT: 6758 I have no ide why it *added* NIR instructions but aparently it did. However, they were things that the back-end was getting rid of anyway. Any idea why? --Jason > I think it's also worth noting that piglit probably isn't a good test > of whether or not this works. I doubt there are many piglit shaders > with dead control-flow and I think GLSL IR can get rid of it in some > of the common cases. If you wanted to "generate NIR" to test with, > you could always hack up my SPIRV -> NIR branch to run an optimization > loop after converting. Then you can see what happens without GLSL IR > in the way. > --Jason > >> This is rebased on Jason's series to use lists for use-def sets; it >> turns out that the changes required were pretty minimal. >> >> The series is also available at: >> >> git://people.freedesktop.org/~cwabbott0/mesa nir-dead-cf-v3 >> >> Connor Abbott (9): >> nir/vars_to_ssa: don't rewrite removed instructions >> nir: insert ssa_undef instructions when cleanup up defs/uses >> nir: add an optimization for removing dead control flow >> nir/validate: validate successors at the end of a loop >> nir/dead_cf: delete code that's unreachable due to jumps >> nir: add nir_block_get_following_loop() helper >> nir: add a helper for iterating over blocks in a cf node >> nir/dead_cf: add support for removing useless loops >> i965/fs/nir: enable the dead control flow optimization >> >> src/glsl/Makefile.sources | 1 + >> src/glsl/nir/nir.c | 94 ++++++++-- >> src/glsl/nir/nir.h | 12 ++ >> src/glsl/nir/nir_lower_vars_to_ssa.c | 3 +- >> src/glsl/nir/nir_opt_dead_cf.c | 332 >> +++++++++++++++++++++++++++++++++++ >> src/glsl/nir/nir_validate.c | 21 +++ >> src/mesa/drivers/dri/i965/brw_nir.c | 2 + >> 7 files changed, 452 insertions(+), 13 deletions(-) >> create mode 100644 src/glsl/nir/nir_opt_dead_cf.c >> >> -- >> 2.1.0 >> >> _______________________________________________ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev