Bug 42594 - no store merging for structure stores
Summary: no store merging for structure stores
Status: RESOLVED DUPLICATE of bug 22141
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-03 13:09 UTC by Andi Kleen
Modified: 2010-01-03 13:30 UTC (History)
10 users (show)

See Also:
Host: x86_64-linux
Target: x86_64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-01-03 13:22:11


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andi Kleen 2010-01-03 13:09:16 UTC
Extracted from
http://embed.cs.utah.edu/embarrassing/dec_09/harvest/gcc-head_llvm-gcc-head/

I've seen this in multiple examples both compared to llvm and icc.
The other compilers merge adjacent stores to structures in memory,
gcc doesn't.

Simple toy example:

struct foo { 
        short a;
        char c;
        char d;
        int x;
};

void f(struct foo *f)
{
        f->a = 1;
        f->c = 0;
        f->d = 1;
        f->x = 0;
}


generates with -O2 -S -mtune=generic 4.5.0 20091219

 movw    $1, (%rdi)
 movb    $0, 2(%rdi)
 movb    $1, 3(%rdi)
 movl    $0, 4(%rdi)

but since everything is aligned it could be just (from icc)

   movl      $16777217, (%rdi)                             #11.2
   movl      $0, 4(%rdi)                                   #14.2

(possibly even a single movq, exploiting CPUs with very fast misalignment
support like Nehalem)
Comment 1 Richard Biener 2010-01-03 13:20:20 UTC
Old problem - there's a duplicate report even somewhere with a patch from
Jakub.
Comment 2 Steven Bosscher 2010-01-03 13:22:01 UTC
Not sure, but looks like a dup of bug 22141.
Comment 3 Richard Biener 2010-01-03 13:30:26 UTC
It is.

*** This bug has been marked as a duplicate of 22141 ***