From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24549 invoked by alias); 13 Apr 2007 15:27:53 -0000 Received: (qmail 24268 invoked by uid 48); 13 Apr 2007 15:27:36 -0000 Date: Fri, 13 Apr 2007 15:27:00 -0000 Message-ID: <20070413152736.24267.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/30398] memmove for string operations In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "tobi at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-04/txt/msg00935.txt.bz2 ------- 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; : _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