[Mesa-dev] [PATCH 3/9] nir: Add lowering of POW instructions if the lower flag is set.

Erik Faye-Lund kusmabite at gmail.com
Mon Feb 2 04:03:20 PST 2015


On Sun, Feb 1, 2015 at 10:17 PM, Eric Anholt <eric at anholt.net> wrote:
> This could be done in a separate pass like we do in GLSL IR, but it seems
> to me like having the definitions of the transformations in the two
> directions next to each other makes a lot of sense.
> ---
>  src/glsl/nir/nir_opt_algebraic.py | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
> index 2414f71..41bfe04 100644
> --- a/src/glsl/nir/nir_opt_algebraic.py
> +++ b/src/glsl/nir/nir_opt_algebraic.py
> @@ -107,6 +107,7 @@ optimizations = [
>     (('fexp',  ('flog',  a)), a), # e^ln(a)  = a
>     (('flog2', ('fexp2', a)), a), # lg2(2^a) = a
>     (('flog',  ('fexp',  a)), a), # ln(e^a)  = a
> +   (('fpow', a, b), ('fexp2', ('fmul', ('flog2', a), b)), 'options->lower_fpow'), # 2^(lg2(a)*b) = a^b

Maybe update the comment to be "# a^b = 2^(lg2(a)*b)" instead? That
way you're consistent with the other rewrite-rules that seems to list
the source expression first and the replacement second...

>     (('fexp2', ('fmul', ('flog2', a), b)), ('fpow', a, b), '!options->lower_fpow'), # 2^(lg2(a)*b) = a^b
>     (('fexp',  ('fmul', ('flog', a), b)),  ('fpow', a, b), '!options->lower_fpow'), # e^(ln(a)*b) = a^b
>     (('fpow', a, 1.0), a),
> --
> 2.1.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list