Exemplo n.º 1
0
static bool
loop_is_dead(nir_loop *loop)
{
   nir_block *before = nir_cf_node_as_block(nir_cf_node_prev(&loop->cf_node));
   nir_block *after = nir_cf_node_as_block(nir_cf_node_next(&loop->cf_node));

   if (!exec_list_is_empty(&after->instr_list) &&
       nir_block_first_instr(after)->type == nir_instr_type_phi)
      return false;

   if (!nir_foreach_block_in_cf_node(&loop->cf_node, block_has_no_side_effects,
                                     NULL))
      return false;

   nir_function_impl *impl = nir_cf_node_get_function(&loop->cf_node);
   nir_metadata_require(impl, nir_metadata_live_variables |
                              nir_metadata_dominance);

   for (nir_block *cur = after->imm_dom; cur != before; cur = cur->imm_dom) {
      nir_foreach_instr(cur, instr) {
         if (!nir_foreach_ssa_def(instr, def_not_live_out, after))
            return false;
      }
   }

   return true;
}
Exemplo n.º 2
0
void
nir_live_ssa_defs_impl(nir_function_impl *impl)
{
   struct live_ssa_defs_state state;

   /* We start at 1 because we reserve the index value of 0 for ssa_undef
    * instructions.  Those are never live, so their liveness information
    * can be compacted into a single bit.
    */
   state.num_ssa_defs = 1;
   nir_foreach_block(block, impl) {
      nir_foreach_instr(instr, block)
         nir_foreach_ssa_def(instr, index_ssa_def, &state);
   }