public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/67797] New: [ARM] Unnecessary r0 saving for memset call
@ 2015-10-01 14:19 d.salikhov at samsung dot com
  2021-12-27  4:25 ` [Bug middle-end/67797] builtin functions should be able to know when their first argument is returned pinskia at gcc dot gnu.org
  2021-12-27  4:28 ` [Bug tree-optimization/67797] builtin functions should be able to know when their first argument is returned for tail calls pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: d.salikhov at samsung dot com @ 2015-10-01 14:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67797

            Bug ID: 67797
           Summary: [ARM] Unnecessary r0 saving for memset call
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d.salikhov at samsung dot com
  Target Milestone: ---

Compiled with -Os and with -O2 (result is the same):
#include <string.h>

void *my_func(void *s, size_t n)
{
    memset(s, 0, n);
    return s;
}

The generated code is following:

00000000 <my_func>:
   0:   e92d4010        push    {r4, lr}
   4:   e1a02001        mov     r2, r1
   8:   e1a04000        mov     r4, r0
   c:   e3a01000        mov     r1, #0
  10:   ebfffffe        bl      0 <memset>
  14:   e1a00004        mov     r0, r4
  18:   e8bd8010        pop     {r4, pc}

First, copying r0 into r4 is redundant as memset doesn't clobber r0. So the
code could be reduced to:

push    {r4, lr}
mov     r2, r1
mov     r1, #0
bl      0 <memset>
pop     {r4, pc}

That in turn can be simplified more to:

mov     r2, r1
mov     r1, #0
b       0 <memset>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/67797] builtin functions should be able to know when their first argument is returned
  2015-10-01 14:19 [Bug target/67797] New: [ARM] Unnecessary r0 saving for memset call d.salikhov at samsung dot com
@ 2021-12-27  4:25 ` pinskia at gcc dot gnu.org
  2021-12-27  4:28 ` [Bug tree-optimization/67797] builtin functions should be able to know when their first argument is returned for tail calls pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-27  4:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67797

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 92867 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/67797] builtin functions should be able to know when their first argument is returned for tail calls
  2015-10-01 14:19 [Bug target/67797] New: [ARM] Unnecessary r0 saving for memset call d.salikhov at samsung dot com
  2021-12-27  4:25 ` [Bug middle-end/67797] builtin functions should be able to know when their first argument is returned pinskia at gcc dot gnu.org
@ 2021-12-27  4:28 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-27  4:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67797

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 83142 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-27  4:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01 14:19 [Bug target/67797] New: [ARM] Unnecessary r0 saving for memset call d.salikhov at samsung dot com
2021-12-27  4:25 ` [Bug middle-end/67797] builtin functions should be able to know when their first argument is returned pinskia at gcc dot gnu.org
2021-12-27  4:28 ` [Bug tree-optimization/67797] builtin functions should be able to know when their first argument is returned for tail calls pinskia at gcc dot gnu.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).