https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104665
Bug ID: 104665 Summary: Failure to recognize memcpy Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: monad at posteo dot net Target Milestone: --- The following serialization code: void serialize_le(std::byte* __restrict dst, const std::uint32_t* __restrict src) { for (int i = 0; i < 32; ++i, ++src) { *dst++ = static_cast<std::byte>((*src >> 0) & 0xff); *dst++ = static_cast<std::byte>((*src >> 8) & 0xff); *dst++ = static_cast<std::byte>((*src >> 16) & 0xff); *dst++ = static_cast<std::byte>((*src >> 24) & 0xff); } } is not recognized as just copying memory. Both clang and gcc fail to optimize it properly, however gcc creates an "interesting" mess. Flags used are `-std=c++17 -O3 -march=haswell` <https://godbolt.org/z/GM8jqssYd>