[Mesa-dev] [PATCH] nir: Recognize open-coded fmin/fmax.

Kenneth Graunke kenneth at whitecape.org
Wed Feb 11 10:46:42 PST 2015


On Wednesday, February 11, 2015 09:58:28 AM Matt Turner wrote:
> And unfortunately other shaders do the same thing but with >=/<= which
> we can't apply this optimization to because of NaNs.
> 
> instructions in affected programs:     23309 -> 22938 (-1.59%)
> ---
>  src/glsl/nir/nir_opt_algebraic.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
> index a5fe19a..db105d4 100644
> --- a/src/glsl/nir/nir_opt_algebraic.py
> +++ b/src/glsl/nir/nir_opt_algebraic.py
> @@ -82,6 +82,8 @@ optimizations = [
>     (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),
>     (('fne', ('fadd', a, b), 0.0), ('fne', a, ('fneg', b))),
>     (('fge', ('fneg', ('fabs', a)), 0.0), ('feq', a, 0.0)),
> +   (('bcsel', ('flt', a, b), a, b), ('fmin', a, b)),
> +   (('bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
>     (('fmin', ('fmax', a, 0.0), 1.0), ('fsat', a)),
>     # Logical and bit operations
>     (('fand', a, 0.0), 0.0),
> 

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150211/2bbd50da/attachment-0001.sig>


More information about the mesa-dev mailing list