Mesa (master): nir: Only rematerialize comparisons with all SSA sources

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 19 19:45:50 UTC 2019


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

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Fri Jul 19 13:07:39 2019 -0500

nir: Only rematerialize comparisons with all SSA sources

Otherwise, you may end up moving a register read and that could result
in an incorrect shader.  This commit fixes a rendering issue in Elite:
Dangerous.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111152
Fixes: 3ee2e84c60 "nir: Rematerialize compare instructions"
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/compiler/nir/nir_opt_rematerialize_compares.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/compiler/nir/nir_opt_rematerialize_compares.c b/src/compiler/nir/nir_opt_rematerialize_compares.c
index 806dbd2f29a..8af33ab436e 100644
--- a/src/compiler/nir/nir_opt_rematerialize_compares.c
+++ b/src/compiler/nir/nir_opt_rematerialize_compares.c
@@ -58,6 +58,18 @@ is_two_src_comparison(const nir_alu_instr *instr)
 }
 
 static bool
+all_srcs_are_ssa(const nir_alu_instr *instr)
+{
+   for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
+      if (!instr->src[i].src.is_ssa)
+         return false;
+   }
+
+   return true;
+}
+
+
+static bool
 all_uses_are_bcsel(const nir_alu_instr *instr)
 {
    if (!instr->dest.dest.is_ssa)
@@ -96,6 +108,9 @@ nir_opt_rematerialize_compares_impl(nir_shader *shader, nir_function_impl *impl)
          if (!is_two_src_comparison(alu))
             continue;
 
+         if (!all_srcs_are_ssa(alu))
+            continue;
+
          if (!all_uses_are_bcsel(alu))
             continue;
 




More information about the mesa-commit mailing list