[Mesa-dev] [PATCH 5/5] nir: Allow feq/fne/ieq/ine to be optimized with inot.

Glenn Kennard glenn.kennard at gmail.com
Wed May 6 15:06:36 PDT 2015


On Wed, 06 May 2015 23:12:54 +0200, Matt Turner <mattst88 at gmail.com> wrote:

> instructions in affected programs:     380 -> 376 (-1.05%)
> helped:                                2
> ---
> Did we just completely forget these in commit 391fb32b, or is there a
> reason to not include them?
>
>  src/glsl/nir/nir_opt_algebraic.py | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/glsl/nir/nir_opt_algebraic.py  
> b/src/glsl/nir/nir_opt_algebraic.py
> index b0a1f24..400d60e 100644
> --- a/src/glsl/nir/nir_opt_algebraic.py
> +++ b/src/glsl/nir/nir_opt_algebraic.py
> @@ -83,8 +83,12 @@ optimizations = [
>     # Comparison simplifications
>     (('inot', ('flt', a, b)), ('fge', a, b)),
>     (('inot', ('fge', a, b)), ('flt', a, b)),
> +   (('inot', ('feq', a, b)), ('fne', a, b)),
> +   (('inot', ('fne', a, b)), ('feq', a, b)),

These two will produce inverted results for NaN inputs. GLSL 4.5 spec  
doesn't mention requiring ieee754 compliant comparison operators though so  
probably okay.

>     (('inot', ('ilt', a, b)), ('ige', a, b)),
>     (('inot', ('ige', a, b)), ('ilt', a, b)),
> +   (('inot', ('ieq', a, b)), ('ine', a, b)),
> +   (('inot', ('ine', a, b)), ('ieq', a, 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)),


Patches 1-5 are
Reviewed-by: Glenn Kennard <glenn.kennard at gmail.com>


More information about the mesa-dev mailing list