mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 05:00:09 +01:00
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
6 changed files with 12 additions and 6 deletions
|
|
@ -970,6 +970,13 @@ nir_src_is_const(nir_src src)
|
||||||
src.ssa->parent_instr->type == nir_instr_type_load_const;
|
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
|
static inline bool
|
||||||
nir_src_is_divergent(nir_src src)
|
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)
|
if (src->pred == preheader)
|
||||||
continue;
|
continue;
|
||||||
/* skip undef values */
|
/* skip undef values */
|
||||||
if (src->src.ssa->parent_instr->type == nir_instr_type_ssa_undef)
|
if (nir_src_is_undef(src->src))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* check if all loop-carried values are from the same ssa-def */
|
/* 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,
|
copy_types(nir_src src, nir_dest *dest, BITSET_WORD *float_types,
|
||||||
BITSET_WORD *int_types, bool *progress)
|
BITSET_WORD *int_types, bool *progress)
|
||||||
{
|
{
|
||||||
bool src_is_sink = nir_src_is_const(src) ||
|
bool src_is_sink = nir_src_is_const(src) || nir_src_is_undef(src);
|
||||||
src.ssa->parent_instr->type == nir_instr_type_ssa_undef;
|
|
||||||
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, float_types, progress);
|
||||||
copy_type(src.ssa->index, dest->ssa.index, src_is_sink, int_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)
|
if (!src->is_ssa)
|
||||||
return true;
|
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 */
|
return true; /* undefined variables are never live */
|
||||||
|
|
||||||
BITSET_SET(live, src->ssa->index);
|
BITSET_SET(live, src->ssa->index);
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ remove_phis_block(nir_block *block, nir_builder *b)
|
||||||
if (def == NULL) {
|
if (def == NULL) {
|
||||||
def = src->src.ssa;
|
def = src->src.ssa;
|
||||||
mov = get_parent_mov(def);
|
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)) {
|
nir_block_dominates(def->parent_instr->block, src->pred)) {
|
||||||
/* Ignore this undef source. */
|
/* Ignore this undef source. */
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1918,7 +1918,7 @@ fs_visitor::get_nir_src(const nir_src &src)
|
||||||
{
|
{
|
||||||
fs_reg reg;
|
fs_reg reg;
|
||||||
if (src.is_ssa) {
|
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 =
|
const brw_reg_type reg_type =
|
||||||
brw_reg_type_from_bit_size(src.ssa->bit_size, BRW_REGISTER_TYPE_D);
|
brw_reg_type_from_bit_size(src.ssa->bit_size, BRW_REGISTER_TYPE_D);
|
||||||
reg = bld.vgrf(reg_type, src.ssa->num_components);
|
reg = bld.vgrf(reg_type, src.ssa->num_components);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue