mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 14:50:10 +01:00
nir: Use instr_clone in rematerialize_deref_in_block
The previous implementation seems to predate nir_instr_clone() and duplicates a lot of the deref cloning code. This also makes the pass preserve deref->arr.in_bounds correctly. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38856>
This commit is contained in:
parent
dc44c0f32b
commit
2fab8fc297
1 changed files with 4 additions and 38 deletions
|
|
@ -791,52 +791,18 @@ rematerialize_deref_in_block(nir_deref_instr *deref,
|
|||
return deref;
|
||||
|
||||
nir_builder *b = &state->builder;
|
||||
nir_deref_instr *new_deref =
|
||||
nir_deref_instr_create(b->shader, deref->deref_type);
|
||||
new_deref->modes = deref->modes;
|
||||
new_deref->type = deref->type;
|
||||
nir_instr *new_instr = nir_instr_clone(b->shader, &deref->instr);
|
||||
nir_deref_instr *new_deref = nir_instr_as_deref(new_instr);
|
||||
|
||||
if (deref->deref_type == nir_deref_type_var) {
|
||||
new_deref->var = deref->var;
|
||||
} else {
|
||||
if (deref->deref_type != nir_deref_type_var) {
|
||||
nir_deref_instr *parent = nir_src_as_deref(deref->parent);
|
||||
if (parent) {
|
||||
parent = rematerialize_deref_in_block(parent, state);
|
||||
new_deref->parent = nir_src_for_ssa(&parent->def);
|
||||
} else {
|
||||
new_deref->parent = nir_src_for_ssa(deref->parent.ssa);
|
||||
}
|
||||
}
|
||||
|
||||
switch (deref->deref_type) {
|
||||
case nir_deref_type_var:
|
||||
case nir_deref_type_array_wildcard:
|
||||
/* Nothing more to do */
|
||||
break;
|
||||
|
||||
case nir_deref_type_cast:
|
||||
new_deref->cast.ptr_stride = deref->cast.ptr_stride;
|
||||
new_deref->cast.align_mul = deref->cast.align_mul;
|
||||
new_deref->cast.align_offset = deref->cast.align_offset;
|
||||
break;
|
||||
|
||||
case nir_deref_type_array:
|
||||
case nir_deref_type_ptr_as_array:
|
||||
assert(!nir_src_as_deref(deref->arr.index));
|
||||
new_deref->arr.index = nir_src_for_ssa(deref->arr.index.ssa);
|
||||
break;
|
||||
|
||||
case nir_deref_type_struct:
|
||||
new_deref->strct.index = deref->strct.index;
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE("Invalid deref instruction type");
|
||||
}
|
||||
|
||||
nir_def_init(&new_deref->instr, &new_deref->def,
|
||||
deref->def.num_components, deref->def.bit_size);
|
||||
nir_builder_instr_insert(b, &new_deref->instr);
|
||||
nir_builder_instr_insert(b, new_instr);
|
||||
|
||||
return new_deref;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue