public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/50329] New: [PowerPC] Unnecessary stack frame set up
@ 2011-09-08 14:47 sebastian.huber@embedded-brains.de
  2012-07-19  8:11 ` [Bug target/50329] " sebastian.huber@embedded-brains.de
  2024-03-05  0:34 ` bergner at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: sebastian.huber@embedded-brains.de @ 2011-09-08 14:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50329

             Bug #: 50329
           Summary: [PowerPC] Unnecessary stack frame set up
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sebastian.huber@embedded-brains.de
            Target: powerpc-eabi-gcc


Created attachment 25229
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25229
Sample code.

Compiling the attached file with

powerpc-eabi-gcc -O3 -S test.c

yields:

        .file   "test.c"
        .section        ".text"
        .align 2
        .globl a
        .type   a, @function
a:
        stwu 1,-536(1)
        lis 9,0x1234
        lis 0,0x8000
        ori 9,9,22136
        stw 0,0(9)
        addi 1,1,536
        blr
        .size   a, .-a
        .ident  "GCC: (GNU) 4.6.2 20110819 (prerelease)"

This looks pretty good except that a stack frame is set up and teared down.

In case you use the structure definition for memory mapped devices on embedded
systems, then it would be a great deal to save stack space.


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

* [Bug target/50329] [PowerPC] Unnecessary stack frame set up
  2011-09-08 14:47 [Bug target/50329] New: [PowerPC] Unnecessary stack frame set up sebastian.huber@embedded-brains.de
@ 2012-07-19  8:11 ` sebastian.huber@embedded-brains.de
  2024-03-05  0:34 ` bergner at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: sebastian.huber@embedded-brains.de @ 2012-07-19  8:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50329

Sebastian Huber <sebastian.huber@embedded-brains.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #25229|0                           |1
        is obsolete|                            |

--- Comment #1 from Sebastian Huber <sebastian.huber@embedded-brains.de> 2012-07-19 08:11:15 UTC ---
Created attachment 27830
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27830
Sample code

On GCC 4.7.1 20120614 the situation is even more worse:

        .file   "test.c"
        .section        ".text"
        .align 2
        .globl a
        .type   a, @function
a:
        stwu 1,-536(1)
        li 9,0
        stw 9,8(1)
        li 9,-128
        stb 9,8(1)
        lwz 9,8(1)
        addi 1,1,536
        stw 9,0(3)
        blr
        .size   a, .-a
        .align 2
        .globl b
        .type   b, @function
b:
        stwu 1,-544(1)
        mflr 0
        li 4,0
        li 5,516
        stw 31,540(1)
        mr 31,3
        addi 3,1,8
        stw 0,548(1)
        bl memset
        li 9,-128
        stb 9,8(1)
        lwz 9,8(1)
        stw 9,0(31)
        lwz 0,548(1)
        lwz 31,540(1)
        mtlr 0
        addi 1,1,544
        blr
        .size   b, .-b
        .align 2
        .globl c
        .type   c, @function
c:
        li 9,0
        li 10,1
        rlwimi 9,10,31,0,0
        stw 9,0(3)
        blr
        .size   c, .-c
        .ident  "GCC: (GNU) 4.7.1 20120614 (RTEMS
gcc-4.7.1-3.suse12.1/newlib-1.20.0-10.suse12.1)"

Here we see additional store and load operations to assemble the structure
value.

The test case (c) is also sub-optimal since two instructions are sufficient to
load a 32-bit constant.


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

* [Bug target/50329] [PowerPC] Unnecessary stack frame set up
  2011-09-08 14:47 [Bug target/50329] New: [PowerPC] Unnecessary stack frame set up sebastian.huber@embedded-brains.de
  2012-07-19  8:11 ` [Bug target/50329] " sebastian.huber@embedded-brains.de
@ 2024-03-05  0:34 ` bergner at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: bergner at gcc dot gnu.org @ 2024-03-05  0:34 UTC (permalink / raw)
  To: gcc-bugs

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

Peter Bergner <bergner at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bergner at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Peter Bergner <bergner at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #2)
> Current trunk (to be GCC 6) optimises "c" perfectly.  Not the other
> two, alas.

Current trunk (to be GCC 14) optimizes all of them now.  Marking as FIXED.

a:
        li 9,-1
        rldicr 9,9,0,0
        std 9,0(3)
        blr
b:
        li 9,-1
        rldicr 9,9,0,0
        std 9,0(3)
        blr
c:
        li 9,0
        li 10,-1
        rldimi 9,10,63,0
        std 9,0(3)
        blr

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

end of thread, other threads:[~2024-03-05  0:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 14:47 [Bug target/50329] New: [PowerPC] Unnecessary stack frame set up sebastian.huber@embedded-brains.de
2012-07-19  8:11 ` [Bug target/50329] " sebastian.huber@embedded-brains.de
2024-03-05  0:34 ` bergner 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).