nir: Add a nir_deref_tail helper
[mesa.git] / src / glsl / nir / nir_lower_var_copies.c
index 21672901f04c9094146af80378831629c82c8af4..98c107aa50e691447e37c0ae095b19ff5482648e 100644 (file)
@@ -53,17 +53,6 @@ deref_next_wildcard_parent(nir_deref *deref)
    return NULL;
 }
 
-/* Returns the last deref in the chain.
- */
-static nir_deref *
-get_deref_tail(nir_deref *deref)
-{
-   while (deref->child)
-      deref = deref->child;
-
-   return deref;
-}
-
 /* This function recursively walks the given deref chain and replaces the
  * given copy instruction with an equivalent sequence load/store
  * operations.
@@ -121,8 +110,8 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
    } else {
       /* In this case, we have no wildcards anymore, so all we have to do
        * is just emit the load and store operations. */
-      src_tail = get_deref_tail(src_tail);
-      dest_tail = get_deref_tail(dest_tail);
+      src_tail = nir_deref_tail(src_tail);
+      dest_tail = nir_deref_tail(dest_tail);
 
       assert(src_tail->type == dest_tail->type);