Esempio n. 1
0
static bool
dead_cf_block(nir_block *block)
{
   nir_if *following_if = nir_block_get_following_if(block);
   if (following_if) {
     nir_const_value *const_value =
        nir_src_as_const_value(following_if->condition);

     if (!const_value)
        return false;

      opt_constant_if(following_if, const_value->u[0] != 0);
      return true;
   }

   nir_loop *following_loop = nir_block_get_following_loop(block);
   if (!following_loop)
      return false;

   if (!loop_is_dead(following_loop))
      return false;

   nir_cf_node_remove(&following_loop->cf_node);
   return true;
}
Esempio n. 2
0
static bool
init_block(nir_block *block, struct exec_list *worklist)
{
   nir_foreach_instr(instr, block)
      init_instr(instr, worklist);

   nir_if *following_if = nir_block_get_following_if(block);
   if (following_if) {
      if (following_if->condition.is_ssa &&
          !following_if->condition.ssa->parent_instr->pass_flags)
         worklist_push(worklist, following_if->condition.ssa->parent_instr);
   }

   return true;
}
         }
         continue;
      }

      default:
         /* Everything else is an unknown non-boolean value and needs to
          * have all sources resolved.
          */
         instr->pass_flags = (instr->pass_flags & ~BRW_NIR_BOOLEAN_MASK) |
                             BRW_NIR_NON_BOOLEAN;
         nir_foreach_src(instr, src_mark_needs_resolve, NULL);
         continue;
      }
   }

   nir_if *following_if = nir_block_get_following_if(block);
   if (following_if)
      src_mark_needs_resolve(&following_if->condition, NULL);

   return true;
}

static void
analyze_boolean_resolves_impl(nir_function_impl *impl)
{
   nir_foreach_block(impl, analyze_boolean_resolves_block, NULL);
}

void
brw_nir_analyze_boolean_resolves(nir_shader *shader)
{