[Mesa-dev] [PATCH 08/13] nir: Transform -fabs(a) >= 0 to a == 0

Thomas Helland thomashelland90 at gmail.com
Thu Aug 2 21:17:49 UTC 2018


This patch is:

Reviewed-by: Thomas Helland<thomashelland90 at gmail.com>

2018-08-02 20:19 GMT+02:00 Ian Romanick <idr at freedesktop.org>:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> All Gen platforms had pretty similar results. (Skylake shown)
> total instructions in shared programs: 14276964 -> 14276961 (<.01%)
> instructions in affected programs: 411 -> 408 (-0.73%)
> helped: 3
> HURT: 0
> helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1
> helped stats (rel) min: 0.47% max: 1.96% x̄: 1.04% x̃: 0.68%
>
> total cycles in shared programs: 532577062 -> 532577068 (<.01%)
> cycles in affected programs: 1093 -> 1099 (0.55%)
> helped: 1
> HURT: 1
> helped stats (abs) min: 16 max: 16 x̄: 16.00 x̃: 16
> helped stats (rel) min: 7.77% max: 7.77% x̄: 7.77% x̃: 7.77%
> HURT stats (abs)   min: 22 max: 22 x̄: 22.00 x̃: 22
> HURT stats (rel)   min: 2.48% max: 2.48% x̄: 2.48% x̃: 2.48%
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index 4d60467fbac..e1e2ef09845 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -235,6 +235,15 @@ optimizations = [
>     # fabs(a) > 0.0
>     (('~flt', ('fneg', ('fabs', a)), 0.0), ('fne', a, 0.0)),
>
> +   # 0.0 >= fabs(a)
> +   # 0.0 == fabs(a)   because fabs(a) must be >= 0
> +   # 0.0 == a
> +   (('fge', 0.0, ('fabs', a)), ('feq', a, 0.0)),
> +
> +   # -fabs(a) >= 0.0
> +   # 0.0 >= fabs(a)
> +   (('fge', ('fneg', ('fabs', a)), 0.0), ('feq', a, 0.0)),
> +
>     (('fmax',                        ('b2f(is_used_once)', a),           ('b2f', b)),           ('b2f', ('ior', a, b))),
>     (('fmax', ('fneg(is_used_once)', ('b2f(is_used_once)', a)), ('fneg', ('b2f', b))), ('fneg', ('b2f', ('ior', a, b)))),
>     (('fmin',                        ('b2f(is_used_once)', a),           ('b2f', b)),           ('b2f', ('iand', a, b))),
> --
> 2.14.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list