Mesa (staging/22.1): nir/deref: Make compare_deref_paths take a stop callback
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 16 21:43:16 UTC 2022
Module: Mesa
Branch: staging/22.1
Commit: 81f7c1cfd9cc7f7d80790aae00ccdf6e97278dd9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=81f7c1cfd9cc7f7d80790aae00ccdf6e97278dd9
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Fri Jun 3 16:06:33 2022 -0500
nir/deref: Make compare_deref_paths take a stop callback
This will let us use it to compare only the first part of a pair of
deref paths and continue the comparison later.
Tested-by: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Reviewed-by: M Henning <drawoc at darkrefraction.com>
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Cc: mesa-stable at lists.freedesktop.org
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16894>
(cherry picked from commit 130d9d80dbbe4a2e64c8c2b5882f94176ea1e12d)
---
.pick_status.json | 2 +-
src/compiler/nir/nir_deref.c | 23 ++++++++++++++++++-----
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index efbf00a7991..e463de3866b 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4018,7 +4018,7 @@
"description": "nir/deref: Make compare_deref_paths take a stop callback",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null
},
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index 908c8215ee2..95bb5c9a474 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -444,7 +444,7 @@ modes_may_alias(nir_variable_mode a, nir_variable_mode b)
ALWAYS_INLINE static nir_deref_compare_result
compare_deref_paths(nir_deref_path *a_path, nir_deref_path *b_path,
- unsigned *i)
+ unsigned *i, bool (*stop_fn)(const nir_deref_instr *))
{
/* Start off assuming they fully compare. We ignore equality for now. In
* the end, we'll determine that by containment.
@@ -459,6 +459,9 @@ compare_deref_paths(nir_deref_path *a_path, nir_deref_path *b_path,
for (; a[*i] != NULL; (*i)++) {
if (a[*i] != b[*i])
break;
+
+ if (stop_fn && stop_fn(a[*i]))
+ break;
}
/* We're at either the tail or the divergence point between the two deref
@@ -473,17 +476,26 @@ compare_deref_paths(nir_deref_path *a_path, nir_deref_path *b_path,
* different constant indices.
*/
for (unsigned j = *i; a[j] != NULL; j++) {
+ if (stop_fn && stop_fn(a[j]))
+ break;
+
if (a[j]->deref_type == nir_deref_type_cast ||
a[j]->deref_type == nir_deref_type_ptr_as_array)
return nir_derefs_may_alias_bit;
}
for (unsigned j = *i; b[j] != NULL; j++) {
+ if (stop_fn && stop_fn(b[j]))
+ break;
+
if (b[j]->deref_type == nir_deref_type_cast ||
b[j]->deref_type == nir_deref_type_ptr_as_array)
return nir_derefs_may_alias_bit;
}
for (; a[*i] != NULL && b[*i] != NULL; (*i)++) {
+ if (stop_fn && (stop_fn(a[*i]) || stop_fn(b[*i])))
+ break;
+
switch (a[*i]->deref_type) {
case nir_deref_type_array:
case nir_deref_type_array_wildcard: {
@@ -533,9 +545,10 @@ compare_deref_paths(nir_deref_path *a_path, nir_deref_path *b_path,
}
}
- assert(a[*i] == NULL || b[*i] == NULL);
-
- /* If a is longer than b, then it can't contain b */
+ /* If a is longer than b, then it can't contain b. If neither a[i] nor
+ * b[i] are NULL then we aren't at the end of the chain and we know nothing
+ * about containment.
+ */
if (a[*i] != NULL)
result &= ~nir_derefs_a_contains_b_bit;
if (b[*i] != NULL)
@@ -606,7 +619,7 @@ nir_compare_deref_paths(nir_deref_path *a_path,
}
unsigned path_idx = 1;
- return compare_deref_paths(a_path, b_path, &path_idx);
+ return compare_deref_paths(a_path, b_path, &path_idx, NULL);
}
nir_deref_compare_result
More information about the mesa-commit
mailing list