[Mesa-dev] [PATCH 10/10] nir: Add algebraic optimizations for division and reciprocal.

Jason Ekstrand jason at jlekstrand.net
Thu Jan 22 07:31:32 PST 2015


On Jan 22, 2015 3:41 AM, "Kenneth Graunke" <kenneth at whitecape.org> wrote:
>
> These also exist in opt_algebraic.cpp.
>
> total NIR instructions in shared programs: 2011430 -> 2011211 (-0.01%)
> NIR instructions in affected programs:     42221 -> 42002 (-0.52%)
> helped:                                    198
>
> total i965 instructions in shared programs: 6020554 -> 6020118 (-0.01%)
> i965 instructions in affected programs:     84497 -> 84061 (-0.52%)
> helped:                                     394
> HURT:                                       1 (by 1 instruction)

It's encouraging that the percentages are the same.

> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/glsl/nir/nir_opt_algebraic.py | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/glsl/nir/nir_opt_algebraic.py
b/src/glsl/nir/nir_opt_algebraic.py
> index a5b5715..a1ed503 100644
> --- a/src/glsl/nir/nir_opt_algebraic.py
> +++ b/src/glsl/nir/nir_opt_algebraic.py
> @@ -109,6 +109,11 @@ optimizations = [
>     (('fpow', a, 1.0), a),
>     (('fpow', a, 2.0), ('fmul', a, a)),
>     (('fpow', 2.0, a), ('fexp2', a)),
> +   # Division and reciprocal
> +   (('fdiv', 1.0, a), ('frcp', a)),
> +   (('frcp', ('frcp', a)), a),
> +   (('frcp', ('fsqrt', a)), ('frsq', a)),
> +   (('frcp', ('frsq', a)), ('fsqrt', a)),
>
>  # This one may not be exact
>     (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),
> --
> 2.2.2
>
> _______________________________________________
> 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: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150122/0c099639/attachment.html>


More information about the mesa-dev mailing list