From c95aab23c152115cd567541dd134f3fab6f45e78 Mon Sep 17 00:00:00 2001 From: Alex Coplan Date: Tue, 22 Aug 2023 13:37:53 +0100 Subject: [PATCH] rtl-ssa: Add drop_memory_access helper Add a helper routine to access-utils.h which removes the memory access from an access_array, if it has one. gcc/ChangeLog: * rtl-ssa/access-utils.h (drop_memory_access): New. --- gcc/rtl-ssa/access-utils.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/rtl-ssa/access-utils.h b/gcc/rtl-ssa/access-utils.h index fbaaaa2c2d3a..84d386b7d8bd 100644 --- a/gcc/rtl-ssa/access-utils.h +++ b/gcc/rtl-ssa/access-utils.h @@ -51,6 +51,19 @@ memory_access (T accesses) -> decltype (accesses[0]) return nullptr; } +// If ACCESSES has a memory access, drop it. Otherwise, return ACCESSES +// unchanged. +template +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 -- 2.47.2