[Mesa-dev] [PATCH] nir: Add a couple trivial abs optimizations

Ian Romanick idr at freedesktop.org
Mon Jul 23 17:43:53 UTC 2018


Funny thing about this... this is how i915 implements ABS. :)

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 07/23/2018 12:02 AM, Jason Ekstrand wrote:
> Spotted in a shader in Batman: Arkham City.
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index f49b43f3213..ba277fdfd0e 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -229,6 +229,8 @@ optimizations = [
>     (('imax', a, a), a),
>     (('umin', a, a), a),
>     (('umax', a, a), a),
> +   (('fmax', a, ('fneg', a)), ('fabs', a)),
> +   (('imax', a, ('ineg', a)), ('iabs', a)),
>     (('fmin', a, ('fneg', a)), ('fneg', ('fabs', a))),
>     (('imin', a, ('ineg', a)), ('ineg', ('iabs', a))),
>     (('fmin', a, ('fneg', ('fabs', a))), ('fneg', ('fabs', a))),
> 



More information about the mesa-dev mailing list