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>
(cherry picked from commit 9f22b95956cb11ccba12dd9f7e4510851fb744a3)
This commit is contained in:
Friedrich Vock 2024-01-22 18:09:07 +01:00 committed by Eric Engestrom
parent 466ae8c313
commit 3f1d5726cc
2 changed files with 13 additions and 1 deletions

View file

@ -34,7 +34,7 @@
"description": "nir: Handle casts in nir_opt_copy_prop_vars",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

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.
*/