This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/33344] New: if(!z) {a.b = x->b + 1; z = &a; } else if (!x) { a.b = z->b+1; x = &a; } use z->b and x->b; is not optimized
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Sep 2007 00:02:19 -0000
- Subject: [Bug tree-optimization/33344] New: if(!z) {a.b = x->b + 1; z = &a; } else if (!x) { a.b = z->b+1; x = &a; } use z->b and x->b; is not optimized
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Testcase:
struct f { int a; };
int g(struct f *b, struct f *c)
{
struct f g;
if (!b) {
b = &g;
b->a = c->a + 1;
}
else if (!c) {
c = &g;
c->a = b->a + 1;
}
return c->a + b->a;
}
The best way to optimize this is:
struct f { int a; };
int g(struct f *b, struct f *c)
{
int ba, ca;
if (!b) {
ca = c->a;
ba = ca + 1;
}
else if (!c) {
ba = b->a;
ca = ba + 1;
}
else {
ca = c->a;
ba = b->a;
}
return ca + ba;
}
Which avoids the LHS (load-hit-store hazzard) issue on the Cell.
--
Summary: if(!z) {a.b = x->b + 1; z = &a; } else if (!x) { a.b =
z->b+1; x = &a; } use z->b and x->b; is not optimized
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33344