nir: Handle casts in nir_opt_copy_prop_vars

Cc: mesa-stable

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27197>
This commit is contained in:
Friedrich Vock
2024-01-22 18:09:07 +01:00
committed by Marge Bot
parent 6c845ed548
commit 9f22b95956

View File

@@ -1065,6 +1065,12 @@ copy_prop_vars_block(struct copy_prop_var_state *state,
if (nir_deref_mode_must_be(src.instr, ignore))
break;
/* Ignore trivial casts. If trivial casts are applied to array derefs of vectors,
* not doing this causes is_array_deref_of_vector to (wrongly) return false. */
while (src.instr->deref_type == nir_deref_type_cast &&
nir_deref_instr_parent(src.instr) && nir_deref_cast_is_trivial(src.instr))
src.instr = nir_deref_instr_parent(src.instr);
/* Direct array_derefs of vectors operate on the vectors (the parent
* deref). Indirects will be handled like other derefs.
*/
@@ -1157,6 +1163,12 @@ copy_prop_vars_block(struct copy_prop_var_state *state,
nir_deref_and_path dst = { nir_src_as_deref(intrin->src[0]), NULL };
assert(glsl_type_is_vector_or_scalar(dst.instr->type));
/* Ignore trivial casts. If trivial casts are applied to array derefs of vectors,
* not doing this causes is_array_deref_of_vector to (wrongly) return false. */
while (dst.instr->deref_type == nir_deref_type_cast &&
nir_deref_instr_parent(dst.instr) && nir_deref_cast_is_trivial(dst.instr))
dst.instr = nir_deref_instr_parent(dst.instr);
/* Direct array_derefs of vectors operate on the vectors (the parent
* deref). Indirects will be handled like other derefs.
*/