Richard Sandiford <richard.sandif...@arm.com> writes: > Alex Coplan <alex.cop...@arm.com> writes: >> This adds some helpers to access-utils.h for removing accesses from an >> access_array. This is needed by the upcoming aarch64 load/store pair >> fusion pass. >> >> Bootstrapped/regtested as a series on aarch64-linux-gnu, OK for trunk? >> >> gcc/ChangeLog: >> >> * rtl-ssa/access-utils.h (filter_accesses): New. >> (remove_regno_access): New. >> (check_remove_regno_access): New. >> --- >> gcc/rtl-ssa/access-utils.h | 42 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 42 insertions(+) >> >> diff --git a/gcc/rtl-ssa/access-utils.h b/gcc/rtl-ssa/access-utils.h >> index f078625babf..31259d742d9 100644 >> --- a/gcc/rtl-ssa/access-utils.h >> +++ b/gcc/rtl-ssa/access-utils.h >> @@ -78,6 +78,48 @@ drop_memory_access (T accesses) >> return T (arr.begin (), accesses.size () - 1); >> } >> >> +// Filter ACCESSES to return an access_array of only those accesses that >> +// satisfy PREDICATE. Alocate the new array above WATERMARK. >> +template<typename T, typename FilterPredicate> >> +inline T >> +filter_accesses (obstack_watermark &watermark, >> + T accesses, >> + FilterPredicate predicate) >> +{ >> + access_array_builder builder (watermark); >> + builder.reserve (accesses.size ()); >> + auto it = accesses.begin (); >> + auto end = accesses.end (); >> + for (; it != end; it++) >> + if (predicate (*it)) >> + builder.quick_push (*it); > > It looks like the last five lines could be simplified to: > > for (access_info *access : accesses) > if (!predicate (access)) > builder.quick_push (access);
Oops, I meant: if (predicate (access)) of course :)