This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/21602] New: builtin memmove could be memcpy is src and dst don't alias
- From: "ghazi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 May 2005 02:09:01 -0000
- Subject: [Bug middle-end/21602] New: builtin memmove could be memcpy is src and dst don't alias
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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