This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/14703] Inadequate optimization of inline templated functions
- From: "eric-gcc at omnifarious dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Mar 2006 20:25:16 -0000
- Subject: [Bug tree-optimization/14703] Inadequate optimization of inline templated functions
- References: <bug-14703-3016@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from eric-gcc at omnifarious dot org 2006-03-02 20:25 -------
I'm pleased that I came up with such a difficult test case for the optimizer.
I never thought it'd be that hard. :-)
I don't know anything about the internals, but...
The compiler has to generate everything down to the fibconst<0> and fibconst<1>
specializations anyway. So why can't it memoize and filter the optimization
up? Say it generates fibconst<1> and fibconst<2> in order to generate
fibconst<3>, then it discovers that fibconst<3> can be optimized to return
plain old '3'. It can save that, and then when it comes down again needing
fibconst<2> and fibconst<3> in order to generate fibconst<4>, it can see the
already optimized version of fibconst<3> and generate an optimized version of
fibconst<4> that just returns plain old '5'.
Maybe I have things totally wrong and there's no way to do anything like that
with the code. Or maybe it would turn out that that way of doing things is so
special case that it's not worth bothering with.
But, I just wonder if memoizing some sort of optimized version of a function
would help with a lot of things.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14703