This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/82991] memcpy and strcpy return value can be assumed to be equal to first argument
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Nov 2017 12:47:58 +0000
- Subject: [Bug tree-optimization/82991] memcpy and strcpy return value can be assumed to be equal to first argument
- Auto-submitted: auto-generated
- References: <bug-82991-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82991
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |83142
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Another concern was tail-call optimization which needs to learn that
foo (x);
return x;
can be tail-called when foo is returning the argument we return from the
function. Not too difficult to add.
We don't seem to have a testcase verifying tail-calling of memcpy or another
function returning an argument, so this is an invisible regression of the
patch.
struct A { int i; int j; int k; };
void *bar (struct A *dest, struct A *src)
{
return __builtin_memmove (dest, src, sizeof (struct A));
}
is optimized to the following at -O2 but no longer with the current patch:
bar:
.LFB0:
.cfi_startproc
movl $12, %edx
jmp memmove
the following testcase isn't optimized:
struct A { int i; int j; int k; };
void *bar (struct A *dest, struct A *src)
{
__builtin_memmove (dest, src, sizeof (struct A));
return dest;
}
both should be after a suitable fix. -> PR83142.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83142
[Bug 83142] Missed tail-call opportunity