<p dir="ltr"><br>
On Jan 22, 2015 3:41 AM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br>
><br>
> Matt and I noticed a bunch of "val <- ior a a" operations in a shader,<br>
> so we decided to add an algebraic optimization for that.  While there,<br>
> I decided to add a bunch more of them.<br>
><br>
> total NIR instructions in shared programs: 2023511 -> 2020814 (-0.13%)<br>
> NIR instructions in affected programs:     149634 -> 146937 (-1.80%)<br>
> helped:                                    1032<br>
><br>
> i965 already cleans these up, so the final results aren't impressive:<br>
><br>
> total i965 instructions in shared programs: 6035392 -> 6035397 (0.00%)<br>
> i965 instructions in affected programs:     764 -> 769 (0.65%)<br>
> HURT:                                       3<br>
><br>
> However, improving the result of the NIR compile is worth doing.<br>
><br>
> Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> ---<br>
>  src/glsl/nir/nir_opt_algebraic.py | 16 ++++++++++++++++<br>
>  1 file changed, 16 insertions(+)<br>
><br>
> diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py<br>
> index 169bb41..cf16b19 100644<br>
> --- a/src/glsl/nir/nir_opt_algebraic.py<br>
> +++ b/src/glsl/nir/nir_opt_algebraic.py<br>
> @@ -68,6 +68,22 @@ optimizations = [<br>
>     (('fadd', ('fmul', a, b), c), ('ffma', a, b, c)),<br>
>     (('fge', ('fneg', ('fabs', a)), 0.0), ('feq', a, 0.0)),<br>
>     (('fmin', ('fmax', a, 1.0), 0.0), ('fsat', a)),<br>
> +   # Logical and bit operations<br>
> +   (('fand', a, a), a),</p>
<p dir="ltr">This isn't correct.  The fand operation will normalize to 0.0/1.0.</p>
<p dir="ltr">> +   (('fand', a, 0.0), 0.0),</p>
<p dir="ltr">This is ok</p>
<p dir="ltr">> +   (('iand', a, a), a),<br>
> +   (('iand', a, 0), 0),<br>
> +   (('for', a, a), a),<br>
> +   (('for', a, 0.0), a),</p>
<p dir="ltr">Can't do these two either</p>
<p dir="ltr">> +   (('ior', a, a), a),<br>
> +   (('ior', a, 0), a),<br>
> +   (('fxor', a, a), 0.0),</p>
<p dir="ltr">This one should be ok</p>
<p dir="ltr">With the junk optimizations removed,<br>
Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>></p>
<p dir="ltr">> +   (('ixor', a, a), 0),<br>
> +   (('inot', ('inot', a)), a),<br>
> +   # DeMorgan's Laws<br>
> +   (('iand', ('inot', a), ('inot', b)), ('inot', ('ior',  a, b))),<br>
> +   (('ior',  ('inot', a), ('inot', b)), ('inot', ('iand', a, b))),<br>
> +<br>
>  # This one may not be exact<br>
>     (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),<br>
>  ]<br>
> --<br>
> 2.2.2<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>