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

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

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

--- Comment #1 from Sebastian Huber <sebastian.hu...@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.

Reply via email to