From: Alyssa Rosenzweig Date: Tue, 4 Jun 2019 19:54:12 +0000 (+0000) Subject: nir/algebraic: Simplify max(abs(a), 0.0) -> abs(a) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d2d3cc66cf3dfc181780154f69e47c81a08325a1;p=mesa.git nir/algebraic: Simplify max(abs(a), 0.0) -> abs(a) This pattern was noticed in glmark's jellyfish scene. v2: Add inexact qualifier due to NaN behaviour. Minimal shader-db changes (slightly helped). Signed-off-by: Alyssa Rosenzweig Reviewed-by: Elie Tournier --- diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 594f521a66b..d36131ae1ac 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -399,6 +399,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'),