Mesa (main): nir: honor lower_double options for ffloor and ffract

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 16 15:30:11 UTC 2022


Module: Mesa
Branch: main
Commit: 3749a6ecd282cf8c801cda948260fd6d521b92ac
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3749a6ecd282cf8c801cda948260fd6d521b92ac

Author: Gert Wollny <gert.wollny at collabora.com>
Date:   Sun May  8 08:07:36 2022 +0200

nir: honor lower_double options for ffloor and ffract

v2: Don't lower ffloor at 64 to ffract at 64 when both ops are
    to be lowered. Settle on ffloor in opt_algebraic because
    in can be lowered to other ops in lower_double_ops.

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>(v1)
Jason Ekstrand <jason.ekstrand at collabora.com> (v1)

Reviewed-by: Emma Anholt <emma at anholt.net> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16431>

---

 src/compiler/nir/nir_opt_algebraic.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index e7f21ad0b7f..e42443ef025 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -358,9 +358,15 @@ optimizations.extend([
    (('~flrp', a, 0.0, c), ('fadd', ('fmul', ('fneg', a), c), a)),
    (('ftrunc', a), ('bcsel', ('flt', a, 0.0), ('fneg', ('ffloor', ('fabs', a))), ('ffloor', ('fabs', a))), 'options->lower_ftrunc'),
 
-   (('ffloor', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
-   (('fadd', a, ('fneg', ('ffract', a))), ('ffloor', a), '!options->lower_ffloor'),
-   (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
+   (('ffloor at 16', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
+   (('ffloor at 32', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
+   (('ffloor at 64', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor || ((options->lower_doubles_options & nir_lower_dfloor) && !(options->lower_doubles_options & nir_lower_dfloor))'),
+   (('fadd at 16', a, ('fneg', ('ffract', a))), ('ffloor', a), '!options->lower_ffloor'),
+   (('fadd at 32', a, ('fneg', ('ffract', a))), ('ffloor', a), '!options->lower_ffloor'),
+   (('fadd at 64', a, ('fneg', ('ffract', a))), ('ffloor', a), '!options->lower_ffloor && !(options->lower_doubles_options & nir_lower_dfloor)'),
+   (('ffract at 16', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
+   (('ffract at 32', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
+   (('ffract at 64', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract || (options->lower_doubles_options & nir_lower_dfract)'),
    (('fceil', a), ('fneg', ('ffloor', ('fneg', a))), 'options->lower_fceil'),
    (('ffma at 16', a, b, c), ('fadd', ('fmul', a, b), c), 'options->lower_ffma16'),
    (('ffma at 32', a, b, c), ('fadd', ('fmul', a, b), c), 'options->lower_ffma32'),



More information about the mesa-commit mailing list