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

Ilia Mirkin imirkin at alum.mit.edu
Fri May 24 02:54:38 UTC 2019


How does max(NaN, 0) work? IIRC there's some provision that this
becomes 0, while abs(NaN) = NaN.

On Thu, May 23, 2019 at 10:47 PM Alyssa Rosenzweig <alyssa at rosenzweig.io> wrote:
>
> I noticed this pattern in glmark's jellyfish scene.
>
> Assuming this is correct (it should be...?), could someone do a
> shader-db run? Thank you!
>
> Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
> Cc: Ian Romanick <ian.d.romanick at intel.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..abd0b6591ce 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -377,6 +377,7 @@ optimizations = [
>     (('imax', a, a), a),
>     (('umin', a, a), a),
>     (('umax', a, a), a),
> +   (('fmax', ('fabs', a), 0.0), ('fabs', a)),
>     (('fmax', ('fmax', a, b), b), ('fmax', a, b)),
>     (('umax', ('umax', a, b), b), ('umax', a, b)),
>     (('imax', ('imax', a, b), b), ('imax', a, b)),
> --
> 2.20.1
>
> _______________________________________________
> 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