Mesa (main): nouveau/nir: Implement mul_zero_wins behavior for use_legacy_math_rules.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 10 03:54:57 UTC 2022


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

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Apr 26 13:39:28 2022 -0700

nouveau/nir: Implement mul_zero_wins behavior for use_legacy_math_rules.

This is the same flag TGSI sets for LEGACY_MATH_RULES.

Acked-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: M Henning <drawoc at darkrefraction.com>
Tested-by: Mobin Aydinfar <mobin at mobintestserver.ir>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16176>

---

 src/nouveau/codegen/nv50_ir_from_nir.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/nouveau/codegen/nv50_ir_from_nir.cpp b/src/nouveau/codegen/nv50_ir_from_nir.cpp
index d8ccdecf9c8..9f2f791ace4 100644
--- a/src/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -997,6 +997,7 @@ bool Converter::assignSlots() {
    unsigned index;
 
    info->io.viewportId = -1;
+   info->io.mul_zero_wins = nir->info.use_legacy_math_rules;
    info_out->numInputs = 0;
    info_out->numOutputs = 0;
    info_out->numSysVals = 0;
@@ -2585,6 +2586,17 @@ Converter::visit(nir_alu_instr *insn)
          Instruction *i = mkOp(getOperation(op), dType, newDefs[0]);
          for (unsigned s = 0u; s < info.num_inputs; ++s) {
             i->setSrc(s, getSrc(&insn->src[s]));
+
+            if (this->info->io.mul_zero_wins) {
+               switch (op) {
+               case nir_op_fmul:
+               case nir_op_ffma:
+                  i->dnz = true;
+                  break;
+               default:
+                  break;
+               }
+            }
          }
          i->subOp = getSubOp(op);
       }



More information about the mesa-commit mailing list