[Mesa-dev] [PATCH 5/5] nir: Recognize sat(add(b2f(a), b2f(b))) as a logical OR.

Jason Ekstrand jason at jlekstrand.net
Wed Mar 18 19:40:35 PDT 2015


On Wed, Mar 18, 2015 at 11:37 AM, Matt Turner <mattst88 at gmail.com> wrote:
> Transform this into b2f(or(a, b)).
>
> instructions in affected programs:     432 -> 430 (-0.46%)
> helped:                                2
> ---
>  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 f956edf..1ee51a0 100644
> --- a/src/glsl/nir/nir_opt_algebraic.py
> +++ b/src/glsl/nir/nir_opt_algebraic.py
> @@ -97,6 +97,7 @@ optimizations = [
>     (('fmin', ('fmax', ('fmin', ('fmax', a, 0.0), 1.0), 0.0), 1.0), ('fmin', ('fmax', a, 0.0), 1.0)),
>     # Emulating booleans
>     (('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))),
> +   (('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))),

Thanks to the fact that this is an or, this should work regardless of
whether or not a and b are booleans.

Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

>     # Comparison with the same args.  Note that these are not done for
>     # the float versions because NaN always returns false on float
>     # inequalities.
> --
> 2.0.5
>
> _______________________________________________
> 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