nir: Add a nir_src_is_undef() helper, like nir_src_is_const().
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9345>
This commit is contained in:
parent
c77df59c9e
commit
1e5ef4c60c
|
@ -970,6 +970,13 @@ nir_src_is_const(nir_src src)
|
|||
src.ssa->parent_instr->type == nir_instr_type_load_const;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
nir_src_is_undef(nir_src src)
|
||||
{
|
||||
return src.is_ssa &&
|
||||
src.ssa->parent_instr->type == nir_instr_type_ssa_undef;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
nir_src_is_divergent(nir_src src)
|
||||
{
|
||||
|
|
|
@ -746,7 +746,7 @@ visit_loop_header_phi(nir_phi_instr *phi, nir_block *preheader, bool divergent_c
|
|||
if (src->pred == preheader)
|
||||
continue;
|
||||
/* skip undef values */
|
||||
if (src->src.ssa->parent_instr->type == nir_instr_type_ssa_undef)
|
||||
if (nir_src_is_undef(src->src))
|
||||
continue;
|
||||
|
||||
/* check if all loop-carried values are from the same ssa-def */
|
||||
|
|
|
@ -72,8 +72,7 @@ static void
|
|||
copy_types(nir_src src, nir_dest *dest, BITSET_WORD *float_types,
|
||||
BITSET_WORD *int_types, bool *progress)
|
||||
{
|
||||
bool src_is_sink = nir_src_is_const(src) ||
|
||||
src.ssa->parent_instr->type == nir_instr_type_ssa_undef;
|
||||
bool src_is_sink = nir_src_is_const(src) || nir_src_is_undef(src);
|
||||
copy_type(src.ssa->index, dest->ssa.index, src_is_sink, float_types, progress);
|
||||
copy_type(src.ssa->index, dest->ssa.index, src_is_sink, int_types, progress);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ set_src_live(nir_src *src, void *void_live)
|
|||
if (!src->is_ssa)
|
||||
return true;
|
||||
|
||||
if (src->ssa->parent_instr->type == nir_instr_type_ssa_undef)
|
||||
if (nir_src_is_undef(*src))
|
||||
return true; /* undefined variables are never live */
|
||||
|
||||
BITSET_SET(live, src->ssa->index);
|
||||
|
|
|
@ -98,7 +98,7 @@ remove_phis_block(nir_block *block, nir_builder *b)
|
|||
if (def == NULL) {
|
||||
def = src->src.ssa;
|
||||
mov = get_parent_mov(def);
|
||||
} else if (src->src.ssa->parent_instr->type == nir_instr_type_ssa_undef &&
|
||||
} else if (nir_src_is_undef(src->src) &&
|
||||
nir_block_dominates(def->parent_instr->block, src->pred)) {
|
||||
/* Ignore this undef source. */
|
||||
} else {
|
||||
|
|
|
@ -1918,7 +1918,7 @@ fs_visitor::get_nir_src(const nir_src &src)
|
|||
{
|
||||
fs_reg reg;
|
||||
if (src.is_ssa) {
|
||||
if (src.ssa->parent_instr->type == nir_instr_type_ssa_undef) {
|
||||
if (nir_src_is_undef(src)) {
|
||||
const brw_reg_type reg_type =
|
||||
brw_reg_type_from_bit_size(src.ssa->bit_size, BRW_REGISTER_TYPE_D);
|
||||
reg = bld.vgrf(reg_type, src.ssa->num_components);
|
||||
|
|
Loading…
Reference in New Issue