summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2016-04-12 14:43:16 -0400
committerJason Ekstrand <[email protected]>2016-04-28 15:52:17 -0700
commit52affdd2e6f530b43abafcc56867510cc790e3e2 (patch)
treec07d02717b66db56e41e688c5bcff91188f4622e /src/compiler/nir
parentddc6639f8596d0d44d84e0b0fd3a5461c953c4b2 (diff)
nir/opt_dead_cf: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_opt_dead_cf.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/compiler/nir/nir_opt_dead_cf.c b/src/compiler/nir/nir_opt_dead_cf.c
index d397695785f..a8506b7d36a 100644
--- a/src/compiler/nir/nir_opt_dead_cf.c
+++ b/src/compiler/nir/nir_opt_dead_cf.c
@@ -135,33 +135,33 @@ opt_constant_if(nir_if *if_stmt, bool condition)
}
static bool
-block_has_no_side_effects(nir_block *block, void *state)
+cf_node_has_side_effects(nir_cf_node *node)
{
- (void) state;
+ nir_foreach_block_in_cf_node(block, node) {
+ nir_foreach_instr(block, instr) {
+ if (instr->type == nir_instr_type_call)
+ return true;
- nir_foreach_instr(block, instr) {
- if (instr->type == nir_instr_type_call)
- return false;
+ /* Return instructions can cause us to skip over other side-effecting
+ * instructions after the loop, so consider them to have side effects
+ * here.
+ */
- /* Return instructions can cause us to skip over other side-effecting
- * instructions after the loop, so consider them to have side effects
- * here.
- */
+ if (instr->type == nir_instr_type_jump &&
+ nir_instr_as_jump(instr)->type == nir_jump_return)
+ return true;
- if (instr->type == nir_instr_type_jump &&
- nir_instr_as_jump(instr)->type == nir_jump_return)
- return false;
-
- if (instr->type != nir_instr_type_intrinsic)
- continue;
+ if (instr->type != nir_instr_type_intrinsic)
+ continue;
- nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
- if (!nir_intrinsic_infos[intrin->intrinsic].flags &
- NIR_INTRINSIC_CAN_ELIMINATE)
- return false;
+ nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+ if (!nir_intrinsic_infos[intrin->intrinsic].flags &
+ NIR_INTRINSIC_CAN_ELIMINATE)
+ return true;
+ }
}
- return true;
+ return false;
}
static bool
@@ -199,8 +199,7 @@ loop_is_dead(nir_loop *loop)
nir_block_first_instr(after)->type == nir_instr_type_phi)
return false;
- if (!nir_foreach_block_in_cf_node_call(&loop->cf_node, block_has_no_side_effects,
- NULL))
+ if (cf_node_has_side_effects(&loop->cf_node))
return false;
nir_function_impl *impl = nir_cf_node_get_function(&loop->cf_node);