Add a helper routine to access-utils.h which removes the memory access
from an access_array, if it has one.

Bootstrapped/regtested as a series on aarch64-linux-gnu, OK for trunk?

gcc/ChangeLog:

        * rtl-ssa/access-utils.h (drop_memory_access): New.
---
 gcc/rtl-ssa/access-utils.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/rtl-ssa/access-utils.h b/gcc/rtl-ssa/access-utils.h
index fbaaaa2c2d3..0c108b18bb8 100644
--- a/gcc/rtl-ssa/access-utils.h
+++ b/gcc/rtl-ssa/access-utils.h
@@ -51,6 +51,17 @@ memory_access (T accesses) -> decltype (accesses[0])
   return nullptr;
 }
 
+template<typename T>
+inline T
+drop_memory_access (T accesses)
+{
+  if (!memory_access (accesses))
+    return accesses;
+
+  access_array arr (accesses);
+  return T (arr.begin (), accesses.size () - 1);
+}
+
 // If sorted array ACCESSES includes a reference to REGNO, return the
 // access, otherwise return null.
 template<typename T>

Reply via email to