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 middle-end/29158] New: store merge optimization not done


In the example below, define T as "char" or "short". (probably "int" too on a
64-bit machine, with minor adjustment to the example code) Compile the code
with "-Os -S" and observe the assembly. Even if there are no aliasing or
alignment issues, the compiler fails to merge multiple stores into larger
stores.

This is tested with three gcc 4.1 compilers:

i386 from Fedora Core 6 test2
x86-64 from Fedora Core 6 test2
ppc32 from Debian-unstable

BTW, I hope I guessed right in filing against "middle-end". I didn't know if it
was tree-optimization or rtl-optimization, and there still isn't an obvious
place to file bugs which are common to both C and C++.

-------------------------------------
tmp 0 $ cat e.c
#ifndef T
#define T short
#endif

typedef struct S{
        T a;
        T b;
        T c;
        T d;
}S;

S *structbug(S *s){
        s->a = 1;
        s->b = 2;
        s->c = 3;
        s->d = 4;
        return s;
}

T *arraybug(T *s){
        s[0] = 1;
        s[1] = 2;
        s[2] = 3;
        s[3] = 4;
        return s;
}

tmp 0 $ gcc -W -Wall -m32 -Os -fomit-frame-pointer -S e.c
tmp 0 $ cat e.s
        .file   "e.c"
        .text
.globl structbug
        .type   structbug, @function
structbug:
        movl    4(%esp), %eax
        movw    $1, (%eax)
        movw    $2, 2(%eax)
        movw    $3, 4(%eax)
        movw    $4, 6(%eax)
        ret
        .size   structbug, .-structbug
.globl arraybug
        .type   arraybug, @function
arraybug:
        movl    4(%esp), %eax
        movw    $1, (%eax)
        movw    $2, 2(%eax)
        movw    $3, 4(%eax)
        movw    $4, 6(%eax)
        ret
        .size   arraybug, .-arraybug
        .ident  "GCC: (GNU) 4.1.1 20060828 (Red Hat 4.1.1-20)"
        .section        .note.GNU-stack,"",@progbits
tmp 0 $


-- 
           Summary: store merge optimization not done
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: acahalan at gmail dot com


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


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