nir/find_array_copies: Properly discard copies for casts
In9f3c595dfc
, we attempted to handle casts in opt_find_array_copies but missed a critical case. In particular, in the case where we begin finding a copy but then encounter a cast, we need to discard everything which might alias that cast. Fixes:9f3c595dfc
"nir/find_array_copies: Handle cast derefs" Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6871>
This commit is contained in:

committed by
Marge Bot

parent
1c49299535
commit
100a5ace63
@@ -190,6 +190,17 @@ node_for_path_with_wildcard(nir_deref_path *path, unsigned wildcard_idx,
|
||||
|
||||
typedef void (*match_cb)(struct match_node *, struct match_state *);
|
||||
|
||||
static void
|
||||
_foreach_child(match_cb cb, struct match_node *node, struct match_state *state)
|
||||
{
|
||||
if (node->num_children == 0) {
|
||||
cb(node, state);
|
||||
} else {
|
||||
for (unsigned i = 0; i < node->num_children; i++)
|
||||
_foreach_child(cb, node->children[i], state);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_foreach_aliasing(nir_deref_instr **deref, match_cb cb,
|
||||
struct match_node *node, struct match_state *state)
|
||||
@@ -233,22 +244,15 @@ _foreach_aliasing(nir_deref_instr **deref, match_cb cb,
|
||||
return;
|
||||
}
|
||||
|
||||
case nir_deref_type_cast:
|
||||
_foreach_child(cb, node, state);
|
||||
return;
|
||||
|
||||
default:
|
||||
unreachable("bad deref type");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_foreach_child(match_cb cb, struct match_node *node, struct match_state *state)
|
||||
{
|
||||
if (node->num_children == 0) {
|
||||
cb(node, state);
|
||||
} else {
|
||||
for (unsigned i = 0; i < node->num_children; i++)
|
||||
_foreach_child(cb, node->children[i], state);
|
||||
}
|
||||
}
|
||||
|
||||
/* Given a deref path, find all the leaf deref nodes that alias it. */
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user