public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/21602] New: builtin memmove could be memcpy is src and dst don't alias
@ 2005-05-16 2:09 ghazi at gcc dot gnu dot org
2005-05-16 2:20 ` [Bug middle-end/21602] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: ghazi at gcc dot gnu dot org @ 2005-05-16 2:09 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/21602] builtin memmove could be memcpy is src and dst don't alias
2005-05-16 2:09 [Bug middle-end/21602] New: builtin memmove could be memcpy is src and dst don't alias ghazi at gcc dot gnu dot org
@ 2005-05-16 2:20 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-16 2:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-16 02:19 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-05-16 02:19:01
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21602
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-16 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-16 2:09 [Bug middle-end/21602] New: builtin memmove could be memcpy is src and dst don't alias ghazi at gcc dot gnu dot org
2005-05-16 2:20 ` [Bug middle-end/21602] " pinskia at gcc dot gnu dot org
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).