This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/82991] memcpy and strcpy return value can be assumed to be equal to first argument


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]