mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-11 10:10:14 +01:00
nir: Make is_trivial_deref_cast public
Cc: mesa-stable
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27197>
(cherry picked from commit 6c845ed548)
This commit is contained in:
parent
d2094c1e1b
commit
466ae8c313
3 changed files with 16 additions and 8 deletions
|
|
@ -44,7 +44,7 @@
|
|||
"description": "nir: Make is_trivial_deref_cast public",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -1668,6 +1668,12 @@ typedef struct {
|
|||
nir_def def;
|
||||
} nir_deref_instr;
|
||||
|
||||
/**
|
||||
* Returns true if the cast is trivial, i.e. the source and destination type is
|
||||
* the same.
|
||||
*/
|
||||
bool nir_deref_cast_is_trivial(nir_deref_instr *cast);
|
||||
|
||||
/** Returns true if deref might have one of the given modes
|
||||
*
|
||||
* For multi-mode derefs, this returns true if any of the possible modes for
|
||||
|
|
|
|||
|
|
@ -26,9 +26,11 @@
|
|||
#include "nir.h"
|
||||
#include "nir_builder.h"
|
||||
|
||||
static bool
|
||||
is_trivial_deref_cast(nir_deref_instr *cast)
|
||||
bool
|
||||
nir_deref_cast_is_trivial(nir_deref_instr *cast)
|
||||
{
|
||||
assert(cast->deref_type == nir_deref_type_cast);
|
||||
|
||||
nir_deref_instr *parent = nir_src_as_deref(cast->parent);
|
||||
if (!parent)
|
||||
return false;
|
||||
|
|
@ -57,7 +59,7 @@ nir_deref_path_init(nir_deref_path *path,
|
|||
|
||||
*tail = NULL;
|
||||
for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
|
||||
if (d->deref_type == nir_deref_type_cast && is_trivial_deref_cast(d))
|
||||
if (d->deref_type == nir_deref_type_cast && nir_deref_cast_is_trivial(d))
|
||||
continue;
|
||||
count++;
|
||||
if (count <= max_short_path_len)
|
||||
|
|
@ -80,7 +82,7 @@ nir_deref_path_init(nir_deref_path *path,
|
|||
head = tail = path->path + count;
|
||||
*tail = NULL;
|
||||
for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
|
||||
if (d->deref_type == nir_deref_type_cast && is_trivial_deref_cast(d))
|
||||
if (d->deref_type == nir_deref_type_cast && nir_deref_cast_is_trivial(d))
|
||||
continue;
|
||||
*(--head) = d;
|
||||
}
|
||||
|
|
@ -987,7 +989,7 @@ opt_alu_of_cast(nir_alu_instr *alu)
|
|||
static bool
|
||||
is_trivial_array_deref_cast(nir_deref_instr *cast)
|
||||
{
|
||||
assert(is_trivial_deref_cast(cast));
|
||||
assert(nir_deref_cast_is_trivial(cast));
|
||||
|
||||
nir_deref_instr *parent = nir_src_as_deref(cast->parent);
|
||||
|
||||
|
|
@ -1231,7 +1233,7 @@ opt_deref_cast(nir_builder *b, nir_deref_instr *cast)
|
|||
return true;
|
||||
|
||||
progress |= opt_remove_cast_cast(cast);
|
||||
if (!is_trivial_deref_cast(cast))
|
||||
if (!nir_deref_cast_is_trivial(cast))
|
||||
return progress;
|
||||
|
||||
/* If this deref still contains useful alignment information, we don't want
|
||||
|
|
@ -1283,7 +1285,7 @@ opt_deref_ptr_as_array(nir_builder *b, nir_deref_instr *deref)
|
|||
*/
|
||||
if (parent->deref_type == nir_deref_type_cast &&
|
||||
parent->cast.align_mul == 0 &&
|
||||
is_trivial_deref_cast(parent))
|
||||
nir_deref_cast_is_trivial(parent))
|
||||
parent = nir_deref_instr_parent(parent);
|
||||
nir_def_rewrite_uses(&deref->def,
|
||||
&parent->def);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue