nir/cursor: Add a constructor for the end of a block but before the jump
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 29 Aug 2015 00:17:39 +0000 (17:17 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 9 Sep 2015 19:28:51 +0000 (12:28 -0700)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/nir/nir.h
src/glsl/nir/nir_from_ssa.c

index 3c375f30c5321bf57a8afc263c3bd93c8cbc0ce9..2bcd18aabe57b67583acc1cf43ff4e3ed153a696 100644 (file)
@@ -1607,6 +1607,17 @@ nir_after_instr(nir_instr *instr)
    return cursor;
 }
 
+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)
 {
index 1fd8b24d33dd07e0e435b9a6c2c014d18aca111b..94002f18cd78f603c14db71c28dc010d75f44d93 100644 (file)
@@ -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;