summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_opt_dce.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-10-29 16:25:51 -0700
committerJason Ekstrand <[email protected]>2015-01-15 07:19:00 -0800
commitd7e482d32cf0188a1ed49e76f008837be5cfd720 (patch)
tree930b26ec87e89af39d2894f81758a07e20dd6e41 /src/glsl/nir/nir_opt_dce.c
parentdfdf0c46732dd20b5796778dc446fb0a34649f1e (diff)
nir: Add a function to detect if a block is immediately followed by an if
Since we don't actually have an "if" instruction, this is a very common pattern when iterating over instructions. This adds a helper function for it to make things a little less painful. Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_opt_dce.c')
-rw-r--r--src/glsl/nir/nir_opt_dce.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/glsl/nir/nir_opt_dce.c b/src/glsl/nir/nir_opt_dce.c
index c18ba328573..c3bbcb4d82d 100644
--- a/src/glsl/nir/nir_opt_dce.c
+++ b/src/glsl/nir/nir_opt_dce.c
@@ -123,13 +123,11 @@ init_block_cb(nir_block *block, void *_state)
nir_foreach_instr(block, instr)
init_instr(instr, worklist);
- if (block->cf_node.node.next != NULL && /* check that we aren't the end node */
- !nir_cf_node_is_last(&block->cf_node) &&
- nir_cf_node_next(&block->cf_node)->type == nir_cf_node_if) {
- nir_if *if_stmt = nir_cf_node_as_if(nir_cf_node_next(&block->cf_node));
- if (if_stmt->condition.is_ssa &&
- !if_stmt->condition.ssa->parent_instr->live)
- worklist_push(worklist, if_stmt->condition.ssa->parent_instr);
+ nir_if *following_if = nir_block_following_if(block);
+ if (following_if) {
+ if (following_if->condition.is_ssa &&
+ !following_if->condition.ssa->parent_instr->live)
+ worklist_push(worklist, following_if->condition.ssa->parent_instr);
}
return true;