This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/32698] [4.3 regression] inefficient pointer expression
- From: "zippel at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jul 2007 17:42:03 -0000
- Subject: [Bug tree-optimization/32698] [4.3 regression] inefficient pointer expression
- References: <bug-32698-14001@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from zippel at gcc dot gnu dot org 2007-07-09 17:42 -------
(In reply to comment #7)
> On the backend side we have the fwprop pass which is supposed to do
> addressing mode selection and the backend which is supposed to provide
> accurate costs for them.
Let's take your proposed form:
return (*(p + (i + 2) * 4) + *(p + (i + 1) * 4)) + *(p + (i + 3) * 4);
After initial RTL expansion something like this is generated:
t1 = i + 2;
r = *(p + t1 * 4);
t2 = i + 1;
r += *(p + t2 * 4);
t3 = i + 3;
r += *(p + t3 * 4);
The problem is now that it takes until combine until this is generated:
r = *(p + i * 4 + 8);
r += *(p + i * 4 + 4);
r += *(p + i * 4 + 12);
and at this point it's too late. It's easy to blame the back end, but at this
point it's IMHO unrealistic to undo this mess at RTL level. The proper address
form should be generated as early as possible, so that at the time RTL is
generated, it's as close as possible to the final form.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32698