This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/16157] gcc fails to optimize redundant expression (reassocation)
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 04 Mar 2012 00:06:13 +0000
- Subject: [Bug tree-optimization/16157] gcc fails to optimize redundant expression (reassocation)
- Auto-submitted: auto-generated
- References: <bug-16157-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16157
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-03-04 00:06:13 UTC ---
If we rewrite the code to be:
extern int a0, a1, a2, a3, a4;
extern int b0, b1, b2, b3, b4;
void f ()
{
/* this can be optimized to four additions... */
b4 = a4 + (a3 + (a2 + (a1 + a0)));
b3 = a3 + (a2 + (a1 + a0));
b2 = a2 + (a1 + a0);
b1 = a1 + a0;
}
Then it gets optimized.