aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_deref.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-06-28 19:46:01 -0700
committerJason Ekstrand <[email protected]>2018-07-02 12:09:37 -0700
commit893fc2d07d382c0b9563c0b48215a0e260f17d4b (patch)
tree8715c6b8f07cdb13d8d94aedca7d8ff48c1564b6 /src/compiler/nir/nir_deref.c
parent70b16963fc6aa5f8c0e947ea48095bb679a3fa74 (diff)
nir: Add a deref_instr_has_indirect helper
Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_deref.c')
-rw-r--r--src/compiler/nir/nir_deref.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index 1a00157c2fc..22ecde4ecca 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -103,6 +103,24 @@ nir_deref_instr_remove_if_unused(nir_deref_instr *instr)
}
bool
+nir_deref_instr_has_indirect(nir_deref_instr *instr)
+{
+ while (instr->deref_type != nir_deref_type_var) {
+ /* Consider casts to be indirects */
+ if (instr->deref_type == nir_deref_type_cast)
+ return true;
+
+ if (instr->deref_type == nir_deref_type_array &&
+ !nir_src_as_const_value(instr->arr.index))
+ return true;
+
+ instr = nir_deref_instr_parent(instr);
+ }
+
+ return false;
+}
+
+bool
nir_remove_dead_derefs_impl(nir_function_impl *impl)
{
bool progress = false;