From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26386 invoked by alias); 16 May 2005 02:09:24 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 24964 invoked by uid 48); 16 May 2005 02:09:01 -0000 Date: Mon, 16 May 2005 02:09:00 -0000 From: "ghazi at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20050516020856.21602.ghazi@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug middle-end/21602] New: builtin memmove could be memcpy is src and dst don't alias X-Bugzilla-Reason: CC X-SW-Source: 2005-05/txt/msg02160.txt.bz2 List-Id: The current builtin memmove optimizes to memcpy if it can prove that the source pointer is in readonly memory, under the assumption that the destination pointer must be writable and therefore couldn't overlap. However we could generalize this such that if we can prove the source and dest don't alias, then we can do the transformation. E.g. given the following code, we should optimize the memmove call in both foo() and bar(), however we only do foo() in mainline. typedef __SIZE_TYPE__ size_t; extern void *malloc (size_t); extern void *memmove (void *, const void *, size_t); void *foo (void) { void *dst = malloc (13); return memmove (dst, "hello world\n", 13); } void *bar (void *src) { void *dst = malloc(13); return memmove (dst, src, 13); } -- Summary: builtin memmove could be memcpy is src and dst don't alias Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P2 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ghazi at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21602