[Mesa-dev] [PATCH 3/5] nir: Do opt_algebraic in reverse order.

Jason Ekstrand jason at jlekstrand.net
Sun Feb 7 16:06:02 UTC 2016


On Feb 4, 2016 5:45 PM, "Matt Turner" <mattst88 at gmail.com> wrote:
>
> Walking the SSA definitions in order means that we consider the smallest
> algebraic optimizations before larger optimizations. So if a smaller
> rule is part of a larger rule, the smaller one will happen first,
> preventing the larger one from happening.
>
> instructions in affected programs: 32721 -> 32611 (-0.34%)
> helped: 106
>
> Prevents regressions and annoyances in the next commits.

Mind doing just a little tooling to try and determine whether or not this
increases the number of times the optimization loop runs?  Some
Optimizations may immediately allow some other optimization on their result
which will now have to wait until the next time through the loop.
--Jason

> ---
>  src/compiler/nir/nir_algebraic.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_algebraic.py
b/src/compiler/nir/nir_algebraic.py
> index a30652f..77ad35e 100644
> --- a/src/compiler/nir/nir_algebraic.py
> +++ b/src/compiler/nir/nir_algebraic.py
> @@ -216,7 +216,7 @@ ${pass_name}_block(nir_block *block, void *void_state)
>  {
>     struct opt_state *state = void_state;
>
> -   nir_foreach_instr_safe(block, instr) {
> +   nir_foreach_instr_reverse_safe(block, instr) {
>        if (instr->type != nir_instr_type_alu)
>           continue;
>
> @@ -255,7 +255,7 @@ ${pass_name}_impl(nir_function_impl *impl, const bool
*condition_flags)
>     state.progress = false;
>     state.condition_flags = condition_flags;
>
> -   nir_foreach_block(impl, ${pass_name}_block, &state);
> +   nir_foreach_block_reverse(impl, ${pass_name}_block, &state);
>
>     if (state.progress)
>        nir_metadata_preserve(impl, nir_metadata_block_index |
> --
> 2.4.10
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160207/c14018fa/attachment.html>


More information about the mesa-dev mailing list