Mesa (master): nir/cursor: Add a constructor for the end of a block but before the jump

Jason Ekstrand jekstrand at kemper.freedesktop.org
Wed Sep 9 19:31:58 UTC 2015


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Fri Aug 28 17:17:39 2015 -0700

nir/cursor: Add a constructor for the end of a block but before the jump

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/glsl/nir/nir.h          |   11 +++++++++++
 src/glsl/nir/nir_from_ssa.c |    7 +------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 3c375f3..2bcd18a 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1608,6 +1608,17 @@ nir_after_instr(nir_instr *instr)
 }
 
 static inline nir_cursor
+nir_after_block_before_jump(nir_block *block)
+{
+   nir_instr *last_instr = nir_block_last_instr(block);
+   if (last_instr && last_instr->type == nir_instr_type_jump) {
+      return nir_before_instr(last_instr);
+   } else {
+      return nir_after_block(block);
+   }
+}
+
+static inline nir_cursor
 nir_before_cf_node(nir_cf_node *node)
 {
    if (node->type == nir_cf_node_block)
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 1fd8b24..94002f1 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -249,12 +249,7 @@ add_parallel_copy_to_end_of_block(nir_block *block, void *void_state)
       nir_parallel_copy_instr *pcopy =
          nir_parallel_copy_instr_create(state->dead_ctx);
 
-      nir_instr *last_instr = nir_block_last_instr(block);
-      if (last_instr && last_instr->type == nir_instr_type_jump) {
-         nir_instr_insert_before(last_instr, &pcopy->instr);
-      } else {
-         nir_instr_insert_after_block(block, &pcopy->instr);
-      }
+      nir_instr_insert(nir_after_block_before_jump(block), &pcopy->instr);
    }
 
    return true;




More information about the mesa-commit mailing list