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

Alyssa Rosenzweig alyssa at rosenzweig.io
Fri May 24 02:47:35 UTC 2019


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



More information about the mesa-dev mailing list