summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-08-24 12:18:51 -0700
committerKenneth Graunke <[email protected]>2015-08-24 15:10:55 -0700
commit4f2cdd849738019ce9552ee1d5f8dafce8af3f10 (patch)
tree7617e1b8d7cad45d9f4937ae7482c25c3c4578db
parentd7971b41ce3bd5ffce9580b3796b40d3591d6e5e (diff)
nir: Use !block_ends_in_jump() in a few places rather than open-coding.
Connor introduced this helper recently; we should use it here too. I had to move the function earlier in the file for it to be available. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/glsl/nir/nir_control_flow.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c
index 86c7ca2beba..5c03375ac77 100644
--- a/src/glsl/nir/nir_control_flow.c
+++ b/src/glsl/nir/nir_control_flow.c
@@ -47,6 +47,13 @@
*/
/*@{*/
+static bool
+block_ends_in_jump(nir_block *block)
+{
+ return !exec_list_is_empty(&block->instr_list) &&
+ nir_block_last_instr(block)->type == nir_instr_type_jump;
+}
+
static inline void
block_add_pred(nir_block *block, nir_block *pred)
{
@@ -111,14 +118,12 @@ link_non_block_to_block(nir_cf_node *node, nir_block *block)
assert(last_else->type == nir_cf_node_block);
nir_block *last_else_block = nir_cf_node_as_block(last_else);
- if (exec_list_is_empty(&last_then_block->instr_list) ||
- nir_block_last_instr(last_then_block)->type != nir_instr_type_jump) {
+ if (!block_ends_in_jump(last_then_block)) {
unlink_block_successors(last_then_block);
link_blocks(last_then_block, block, NULL);
}
- if (exec_list_is_empty(&last_else_block->instr_list) ||
- nir_block_last_instr(last_else_block)->type != nir_instr_type_jump) {
+ if (!block_ends_in_jump(last_else_block)) {
unlink_block_successors(last_else_block);
link_blocks(last_else_block, block, NULL);
}
@@ -294,14 +299,6 @@ move_successors(nir_block *source, nir_block *dest)
link_blocks(dest, succ1, succ2);
}
-static bool
-block_ends_in_jump(nir_block *block)
-{
- return !exec_list_is_empty(&block->instr_list) &&
- nir_block_last_instr(block)->type == nir_instr_type_jump;
-}
-
-
/* Given a basic block with no successors that has been inserted into the
* control flow tree, gives it the successors it would normally have assuming
* it doesn't end in a jump instruction. Also inserts phi sources with undefs