diff --git a/.pick_status.json b/.pick_status.json index 6e6d8e1c064..e278a0ccac5 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c index f291019c341..436f56626f7 100644 --- a/src/compiler/nir/nir_opt_copy_prop_vars.c +++ b/src/compiler/nir/nir_opt_copy_prop_vars.c @@ -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. */