This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/49872] Missed optimization: Could coalesce neighboring memsets
- From: "sgunderson at bigfoot dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 28 Jul 2011 10:10:11 +0000
- Subject: [Bug tree-optimization/49872] Missed optimization: Could coalesce neighboring memsets
- Auto-submitted: auto-generated
- References: <bug-49872-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49872
--- Comment #2 from sgunderson at bigfoot dot com 2011-07-28 10:09:51 UTC ---
I'm not sure if I've seen exactly this construction in real-world code, but
I've certainly seen examples of the hybrid I sketched out (looking at one was
what motivated me to file the bug), ie. something like:
struct S {
int f[1024];
int g;
};
void func(struct S* s)
{
memset(s->f, 0, sizeof(s->f));
s->g = 0;
}
which I would argue should be rewritten to
void func(struct S* s)
{
memset(s->f, 0, sizeof(s->f) + sizeof(s->g));
}
I'd argue that programmers should not be doing this kind of optimization
themselves, since it's very prone to break when changing the structure,
especially as alignment etc. comes into play.