public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104665] New: Failure to recognize memcpy
@ 2022-02-23 16:50 monad at posteo dot net
  2022-02-23 16:51 ` [Bug tree-optimization/104665] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: monad at posteo dot net @ 2022-02-23 16:50 UTC (permalink / raw)
  To: gcc-bugs

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-24  9:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 16:50 [Bug tree-optimization/104665] New: Failure to recognize memcpy monad at posteo dot net
2022-02-23 16:51 ` [Bug tree-optimization/104665] " redi at gcc dot gnu.org
2022-02-23 16:55 ` monad at posteo dot net
2022-02-23 22:35 ` pinskia at gcc dot gnu.org
2022-02-24  9:57 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).