static bool
try_match_deref(nir_deref_path *base_path, int *path_array_idx,
- nir_deref_path *deref_path, int arr_idx)
+ nir_deref_path *deref_path, int arr_idx,
+ nir_deref_instr *dst)
{
for (int i = 0; ; i++) {
nir_deref_instr *b = base_path->path[i];
/* If we don't have an index into the path yet or if this entry in
* the path is at the array index, see if this is a candidate. We're
* looking for an index which is zero in the base deref and arr_idx
- * in the search deref.
+ * in the search deref and has a matching array size.
*/
if ((*path_array_idx < 0 || *path_array_idx == i) &&
const_b_idx && b_idx == 0 &&
- const_d_idx && d_idx == arr_idx) {
+ const_d_idx && d_idx == arr_idx &&
+ glsl_get_length(nir_deref_instr_parent(b)->type) ==
+ glsl_get_length(nir_deref_instr_parent(dst)->type)) {
*path_array_idx = i;
continue;
}
nir_deref_path_init(&src_path, src, state->dead_ctx);
bool result = try_match_deref(&dst_node->first_src_path,
&dst_node->src_wildcard_idx,
- &src_path, dst_node->next_array_idx);
+ &src_path, dst_node->next_array_idx,
+ *instr);
nir_deref_path_finish(&src_path);
if (!result)
goto reset;