Mesa (master): nir: return progress from lower_idiv

Rob Clark robclark at kemper.freedesktop.org
Sun May 15 21:34:56 UTC 2016


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

Author: Rob Clark <robclark at freedesktop.org>
Date:   Mon May  9 12:36:03 2016 -0400

nir: return progress from lower_idiv

With algebraic-opt support for lowering div to shift, the driver would
like to be able to run this pass *after* the main opt-loop, and then
conditionally re-run the opt-loop if this pass actually lowered some-
thing.

Signed-off-by: Rob Clark <robclark at freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/compiler/nir/nir.h            |  2 +-
 src/compiler/nir/nir_lower_idiv.c | 21 +++++++++++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index dd91994..2227910 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2379,7 +2379,7 @@ typedef struct nir_lower_tex_options {
 bool nir_lower_tex(nir_shader *shader,
                    const nir_lower_tex_options *options);
 
-void nir_lower_idiv(nir_shader *shader);
+bool nir_lower_idiv(nir_shader *shader);
 
 void nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables);
 void nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables);
diff --git a/src/compiler/nir/nir_lower_idiv.c b/src/compiler/nir/nir_lower_idiv.c
index f2e7cde..b1e7aeb 100644
--- a/src/compiler/nir/nir_lower_idiv.c
+++ b/src/compiler/nir/nir_lower_idiv.c
@@ -36,7 +36,7 @@
  * branch out to a pre-optimized shader library routine..
  */
 
-static void
+static bool
 convert_instr(nir_builder *bld, nir_alu_instr *alu)
 {
    nir_ssa_def *numer, *denom, *af, *bf, *a, *b, *q, *r;
@@ -46,7 +46,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu)
    if ((op != nir_op_idiv) &&
        (op != nir_op_udiv) &&
        (op != nir_op_umod))
-      return;
+      return false;
 
    is_signed = (op == nir_op_idiv);
 
@@ -115,30 +115,39 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu)
 
    assert(alu->dest.dest.is_ssa);
    nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(q));
+
+   return true;
 }
 
-static void
+static bool
 convert_impl(nir_function_impl *impl)
 {
    nir_builder b;
    nir_builder_init(&b, impl);
+   bool progress = false;
 
    nir_foreach_block(block, impl) {
       nir_foreach_instr_safe(instr, block) {
          if (instr->type == nir_instr_type_alu)
-            convert_instr(&b, nir_instr_as_alu(instr));
+            progress |= convert_instr(&b, nir_instr_as_alu(instr));
       }
    }
 
    nir_metadata_preserve(impl, nir_metadata_block_index |
                                nir_metadata_dominance);
+
+   return progress;
 }
 
-void
+bool
 nir_lower_idiv(nir_shader *shader)
 {
+   bool progress = false;
+
    nir_foreach_function(function, shader) {
       if (function->impl)
-         convert_impl(function->impl);
+         progress |= convert_impl(function->impl);
    }
+
+   return progress;
 }




More information about the mesa-commit mailing list