mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-25 11:30:29 +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>
This commit is contained in:
parent
f6f7715c58
commit
6c845ed548
2 changed files with 15 additions and 7 deletions
|
|
@ -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