public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tnfchris at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/101197] __builtin_memmove does not perform constant optimizations
Date: Mon, 16 Aug 2021 10:56:01 +0000	[thread overview]
Message-ID: <bug-101197-4-Lnrp84k3LZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101197-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101197

--- Comment #13 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
(In reply to cqwrteur from comment #12)
> (In reply to cqwrteur from comment #11)
> > (In reply to Tamar Christina from comment #10)
> > > (In reply to cqwrteur from comment #9)
> > > > (In reply to Tamar Christina from comment #8)
> > > > > (In reply to Jakub Jelinek from comment #6)
> > > > > > Shouldn't that be a different PR with details?  I mean, this PR is that we
> > > > > > should expand shorter memmove inline even if the regions do overlap.
> > > > > 
> > > > > Sure, I'm still trying to create a minimal representative example (it's C++
> > > > > and templated) unless just pointing at the github is enough. 
> > > > > 
> > > > > To be clear though, just inlining memmove at all will cover most of the
> > > > > distance, it's just that you require less registers.
> > > > 
> > > > inline things like memcpy and memmove will lead to serious binary bloat. The
> > > > compiler usually picks to emit call to libc's memcpy and memmove that is
> > > > usually highly optimized with assembly code.
> > > 
> > > Yes your binary will grow, but on small memcopy and memmove. the calling
> > > overhead, not to mention the register allocation overhead you might get from
> > > having to spill your caller saves more than makes up for it.
> > > 
> > > We already inline memcpy and memset. there's no reason not to do memmove,
> > > especially at -O3.
> > 
> > That is false. inline memcpy and memset only works when the size is constant.
> 
> more for type punning reason.

> but on small memcopy and memmove.(In reply to cqwrteur from comment #11)
> (In reply to Tamar Christina from comment #10)
> > (In reply to cqwrteur from comment #9)
> > > (In reply to Tamar Christina from comment #8)
> > > > (In reply to Jakub Jelinek from comment #6)
> > > > > Shouldn't that be a different PR with details?  I mean, this PR is that we
> > > > > should expand shorter memmove inline even if the regions do overlap.
> > > > 
> > > > Sure, I'm still trying to create a minimal representative example (it's C++
> > > > and templated) unless just pointing at the github is enough. 
> > > > 
> > > > To be clear though, just inlining memmove at all will cover most of the
> > > > distance, it's just that you require less registers.
> > > 
> > > inline things like memcpy and memmove will lead to serious binary bloat. The
> > > compiler usually picks to emit call to libc's memcpy and memmove that is
> > > usually highly optimized with assembly code.
> > 
> > Yes your binary will grow, but on small memcopy and memmove. the calling
> > overhead, not to mention the register allocation overhead you might get from
> > having to spill your caller saves more than makes up for it.
> > 
> > We already inline memcpy and memset. there's no reason not to do memmove,
> > especially at -O3.
> 
> That is false. inline memcpy and memset only works when the size is constant.

How do you think you know when the size is small?

> but on small memcopy and memmove.

By logic this means you know the size is constant.

  parent reply	other threads:[~2021-08-16 10:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 14:36 [Bug tree-optimization/101197] New: " unlvsur at live dot com
2021-06-25  6:22 ` [Bug middle-end/101197] " rguenth at gcc dot gnu.org
2021-06-25  6:55 ` marxin at gcc dot gnu.org
2021-06-25  7:53 ` jakub at gcc dot gnu.org
2021-06-25  8:01 ` jakub at gcc dot gnu.org
2021-08-16 10:23 ` tnfchris at gcc dot gnu.org
2021-08-16 10:29 ` jakub at gcc dot gnu.org
2021-08-16 10:33 ` unlvsur at live dot com
2021-08-16 10:35 ` tnfchris at gcc dot gnu.org
2021-08-16 10:37 ` unlvsur at live dot com
2021-08-16 10:53 ` tnfchris at gcc dot gnu.org
2021-08-16 10:54 ` unlvsur at live dot com
2021-08-16 10:54 ` unlvsur at live dot com
2021-08-16 10:56 ` tnfchris at gcc dot gnu.org [this message]
2021-08-16 11:07 ` unlvsur at live dot com
2021-08-16 11:08 ` unlvsur at live dot com
2021-08-16 12:20 ` rguenth at gcc dot gnu.org
2021-08-18 12:53 ` marxin at gcc dot gnu.org
2021-08-18 15:57 ` tnfchris at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101197-4-Lnrp84k3LZ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).