nir: move ends_in_break() helper to nir_loop_analyze.h
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 1 Jun 2018 05:37:27 +0000 (15:37 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 7 Jun 2018 01:33:04 +0000 (11:33 +1000)
We will use the helper while simplifying potential loop terminators
in the following patch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/nir/nir_loop_analyze.c
src/compiler/nir/nir_loop_analyze.h

index 84da035052dcc507c287ebf789a5ab2d1fbe9bdb..d5281a5faa4dedbb03df1c3be3dc33f10d697f14 100644 (file)
@@ -290,17 +290,6 @@ initialize_ssa_def(nir_ssa_def *def, void *void_state)
    return true;
 }
 
-static inline bool
-ends_in_break(nir_block *block)
-{
-   if (exec_list_is_empty(&block->instr_list))
-      return false;
-
-   nir_instr *instr = nir_block_last_instr(block);
-   return instr->type == nir_instr_type_jump &&
-      nir_instr_as_jump(instr)->type == nir_jump_break;
-}
-
 static bool
 find_loop_terminators(loop_info_state *state)
 {
@@ -315,11 +304,11 @@ find_loop_terminators(loop_info_state *state)
 
          nir_block *last_then = nir_if_last_then_block(nif);
          nir_block *last_else = nir_if_last_else_block(nif);
-         if (ends_in_break(last_then)) {
+         if (nir_block_ends_in_break(last_then)) {
             break_blk = last_then;
             continue_from_blk = last_else;
             continue_from_then = false;
-         } else if (ends_in_break(last_else)) {
+         } else if (nir_block_ends_in_break(last_else)) {
             break_blk = last_else;
             continue_from_blk = last_then;
          }
index 18c2305171709548f52bc2f6d313887e56efb484..7b4ed66ee58f2c816fa7c71cee3a646471963b5c 100644 (file)
@@ -92,4 +92,15 @@ nir_is_trivial_loop_if(nir_if *nif, nir_block *break_block)
    return true;
 }
 
+static inline bool
+nir_block_ends_in_break(nir_block *block)
+{
+   if (exec_list_is_empty(&block->instr_list))
+      return false;
+
+   nir_instr *instr = nir_block_last_instr(block);
+   return instr->type == nir_instr_type_jump &&
+      nir_instr_as_jump(instr)->type == nir_jump_break;
+}
+
 #endif /* NIR_LOOP_ANALYZE_H */