public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/29158]  New: store merge optimization not done
@ 2006-09-21  4:37 acahalan at gmail dot com
  2006-09-21  4:38 ` [Bug middle-end/29158] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: acahalan at gmail dot com @ 2006-09-21  4:37 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2006-11-29  5:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-21  4:37 [Bug middle-end/29158] New: store merge optimization not done acahalan at gmail dot com
2006-09-21  4:38 ` [Bug middle-end/29158] " pinskia at gcc dot gnu dot org
2006-09-21  4:39 ` pinskia at gcc dot gnu dot org
2006-11-29  5:09 ` acahalan at gmail dot com
2006-11-29  5:26 ` pinskia at gcc dot gnu dot 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).