[02/11] rtl-ssa: Add drop_memory_access helper

Message ID ZS7yomVmZjy4PJK1@arm.com
State Accepted
Headers
Series aarch64: Add new load/store pair fusion pass |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Alex Coplan Oct. 17, 2023, 8:46 p.m. UTC
  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(+)
  

Comments

Richard Sandiford Oct. 18, 2023, 5:55 p.m. UTC | #1
Alex Coplan <alex.coplan@arm.com> writes:
> 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);
> +}

There ought to be a comment above the function.  OK with that change, thanks.

Richard

> +
>  // If sorted array ACCESSES includes a reference to REGNO, return the
>  // access, otherwise return null.
>  template<typename T>
  

Patch

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>