Mesa (master): nir: Add a flag for lowering fsat.

Eric Anholt anholt at kemper.freedesktop.org
Wed Feb 18 22:57:23 UTC 2015


Module: Mesa
Branch: master
Commit: 1907a3a7ee4d756b12b6fef32a6e5ea7656436d1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1907a3a7ee4d756b12b6fef32a6e5ea7656436d1

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jan 30 13:53:39 2015 -0800

nir: Add a flag for lowering fsat.

vc4 cse/algebraic-disabled stats:
total instructions in shared programs: 44356 -> 44354 (-0.00%)
instructions in affected programs:     55 -> 53 (-3.64%)

v2: Rebase to master (no TGSI->NIR present)

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org> (v1)

---

 src/glsl/nir/nir.h                |    1 +
 src/glsl/nir/nir_opt_algebraic.py |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 7be1abb..f46ec15 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1329,6 +1329,7 @@ typedef struct nir_function {
 typedef struct nir_shader_compiler_options {
    bool lower_ffma;
    bool lower_fpow;
+   bool lower_fsat;
    bool lower_fsqrt;
    /** lowers fneg and ineg to fsub and isub. */
    bool lower_negate;
diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 83a02b6..c7cb651 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -85,7 +85,8 @@ optimizations = [
    (('fge', ('fneg', ('fabs', a)), 0.0), ('feq', a, 0.0)),
    (('bcsel', ('flt', a, b), a, b), ('fmin', a, b)),
    (('bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
-   (('fmin', ('fmax', a, 0.0), 1.0), ('fsat', a)),
+   (('fmin', ('fmax', a, 0.0), 1.0), ('fsat', a), '!options->lower_fsat'),
+   (('fsat', a), ('fmin', ('fmax', a, 0.0), 1.0), 'options->lower_fsat'),
    # Comparison with the same args.  Note that these are not done for
    # the float versions because NaN always returns false on float
    # inequalities.




More information about the mesa-commit mailing list