From: Alex Coplan Date: Tue, 22 Aug 2023 12:37:53 +0000 (+0100) Subject: rtl-ssa: Add drop_memory_access helper X-Git-Tag: basepoints/gcc-15~5402 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c95aab23c152115cd567541dd134f3fab6f45e78;p=thirdparty%2Fgcc.git 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. --- 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