public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tobi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/30398] memmove for string operations
Date: Fri, 13 Apr 2007 15:27:00 -0000	[thread overview]
Message-ID: <20070413152736.24267.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30398-10391@http.gcc.gnu.org/bugzilla/>



------- Comment #3 from tobi at gcc dot gnu dot org  2007-04-13 16:27 -------
With FX' patch to inline REPEAT (see PR31304), we are left with this as final
dump after a -O compilation:
;; Function MAIN__ (MAIN__)

MAIN__ ()
{
  char[1:] * pstr.1;
  char s[1:1];
  char c[1:2];
  void * D.1004;

<bb 2>:
  _gfortran_set_std (68, 127, 0, 0, 0);
  s[1]{lb: 1 sz: 1} = 97;
  D.1004 = _gfortran_internal_malloc (2);
  pstr.1 = (char[1:] *) D.1004;
  __builtin_memcpy ((char *) pstr.1, &s, 1);
  __builtin_memcpy (pstr.1 + 1B, &s, 1);
  __builtin_memmove (&c, pstr.1, 2);
  _gfortran_internal_free (pstr.1);
  return;

}

The call to memmove makes it way into the assembly, even though pstr and c
can't alias.  This is now an optimizer issue, moving to component
tree-optimization, as the tree-ssa optimizers should be able to eliminate the
memmove in favor of a memcpy.  Or even better, get rid of the whole copying
business and predict the correct results.  If that's possible it would be great
to have a way to get rid of the then unnecessary temporary allocation.


-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org,
                   |                            |fxcoudert at gcc dot gnu dot
                   |                            |org
          Component|fortran                     |tree-optimization


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30398


  parent reply	other threads:[~2007-04-13 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-06 22:05 [Bug fortran/30398] New: " tkoenig at gcc dot gnu dot org
2007-01-06 22:07 ` [Bug fortran/30398] " tkoenig at gcc dot gnu dot org
2007-01-22 10:03 ` fxcoudert at gcc dot gnu dot org
2007-04-13 15:27 ` tobi at gcc dot gnu dot org [this message]
     [not found] <bug-30398-4@http.gcc.gnu.org/bugzilla/>
2020-11-11  9:31 ` [Bug tree-optimization/30398] " tkoenig 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=20070413152736.24267.qmail@sourceware.org \
    --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).