Mesa (main): nir: Split the flag for lowering of fabs and fneg to source modifiers.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 9 03:30:07 UTC 2022


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

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Feb  8 10:07:51 2022 -0800

nir: Split the flag for lowering of fabs and fneg to source modifiers.

i915 and r300 have fneg source modifier but not fabs, and doing it in NIR
can save us some backend pain.

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14938>

---

 src/compiler/nir/nir.h                      | 10 ++++++----
 src/compiler/nir/nir_lower_to_source_mods.c |  4 +++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 92d6d1a6ee7..2837170b13f 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -5070,12 +5070,14 @@ bool nir_lower_atomics_to_ssbo(nir_shader *shader);
 
 typedef enum  {
    nir_lower_int_source_mods = 1 << 0,
-   nir_lower_float_source_mods = 1 << 1,
-   nir_lower_64bit_source_mods = 1 << 2,
-   nir_lower_triop_abs = 1 << 3,
-   nir_lower_all_source_mods = (1 << 4) - 1
+   nir_lower_fabs_source_mods = 1 << 1,
+   nir_lower_fneg_source_mods = 1 << 2,
+   nir_lower_64bit_source_mods = 1 << 3,
+   nir_lower_triop_abs = 1 << 4,
+   nir_lower_all_source_mods = (1 << 5) - 1
 } nir_lower_to_source_mods_flags;
 
+#define nir_lower_float_source_mods (nir_lower_fabs_source_mods | nir_lower_fneg_source_mods)
 
 bool nir_lower_to_source_mods(nir_shader *shader, nir_lower_to_source_mods_flags options);
 
diff --git a/src/compiler/nir/nir_lower_to_source_mods.c b/src/compiler/nir/nir_lower_to_source_mods.c
index fa53bac2914..b44189db5ab 100644
--- a/src/compiler/nir/nir_lower_to_source_mods.c
+++ b/src/compiler/nir/nir_lower_to_source_mods.c
@@ -78,8 +78,10 @@ nir_lower_to_source_mods_block(nir_block *block,
          case nir_type_float:
             if (!(options & nir_lower_float_source_mods))
                continue;
-            if (parent->op != nir_op_fabs && parent->op != nir_op_fneg)
+            if (!(parent->op == nir_op_fabs && (options & nir_lower_fabs_source_mods)) &&
+                !(parent->op == nir_op_fneg && (options & nir_lower_fneg_source_mods))) {
                continue;
+            }
             break;
          case nir_type_int:
             if (!(options & nir_lower_int_source_mods))



More information about the mesa-commit mailing list