[Mesa-dev] [PATCH v2 1/2] nir/algebraic: Simplify max(abs(a), 0.0) -> abs(a)

Elie Tournier tournier.elie at gmail.com
Mon May 27 09:30:47 UTC 2019


On Sun, May 26, 2019 at 01:52:44AM +0000, Alyssa Rosenzweig wrote:
> I noticed this pattern in glmark's jellyfish scene.
> 
> v2: Add inexact qualifier to avoid changing NaN behaviour
> 
> I would appreciate if someone did a shader-db run.
> 
> Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Reviewed-by: Elie Tournier <tournier.elie at gmail.com>

For the shader-db, I got:

total instructions in shared programs: 12839341 -> 12839254 (<.01%)
instructions in affected programs: 5885 -> 5798 (-1.48%)
helped: 41
HURT: 0

total cycles in shared programs: 302490031 -> 302487788 (<.01%)
cycles in affected programs: 485428 -> 483185 (-0.46%)
helped: 20
HURT: 1

> Cc: Ilia Mirkin <imirkin at alum.mit.edu>
> Cc: Ian Romanick <idr at freedesktop.org>
> Cc: Elie Tournier <tournier.elie at gmail.com>
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index 89d07aa1261..e607e5b6fe2 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -397,6 +397,7 @@ optimizations = [
>     (('imax', a, ('iabs', a)), ('iabs', a)),
>     (('fmax', a, ('fneg', a)), ('fabs', a)),
>     (('imax', a, ('ineg', a)), ('iabs', a)),
> +   (('~fmax', ('fabs', a), 0.0), ('fabs', a)),
>     (('~fmin', ('fmax', a, 0.0), 1.0), ('fsat', a), '!options->lower_fsat'),
>     (('~fmax', ('fmin', a, 1.0), 0.0), ('fsat', a), '!options->lower_fsat'),
>     (('~fmin', ('fmax', a, -1.0),  0.0), ('fneg', ('fsat', ('fneg', a))), '!options->lower_negate && !options->lower_fsat'),
> -- 
> 2.20.1
> 


More information about the mesa-dev mailing list