diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2020-09-24 13:35:52 -0500 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-10-02 07:30:49 +0000 |
commit | 100a5ace63635214cc3dcad2ebeb1cd7c4901321 (patch) | |
tree | 931a731c58a190ec27521baacba546b895b0059c | |
parent | 1c4929953575ad1216c12737c72f30ca31a7acfc (diff) |
nir/find_array_copies: Properly discard copies for casts
In 9f3c595dfc4cd, 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: 9f3c595dfc4cd "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>
-rw-r--r-- | src/compiler/nir/nir_opt_find_array_copies.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/compiler/nir/nir_opt_find_array_copies.c b/src/compiler/nir/nir_opt_find_array_copies.c index 0e50ca18af9..83f284ecbfc 100644 --- a/src/compiler/nir/nir_opt_find_array_copies.c +++ b/src/compiler/nir/nir_opt_find_array_copies.c @@ -191,6 +191,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 |