This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Simplify/improve fold_Nary_to_constant


Roger Sayle wrote:
Now that Kazu has reorganized fold's internal APIs, its possible to
trivially implement fold_binary_to_constant using fold_binary and
fold_unary_to_constant using fold_unary.  Using the obvious two line
implementations of these functions, avoids creating the tree node
that was the original motiviation for these routines, but also allows
us to catch more optimizations and at the same time reduce the code
duplication.

This patch shrinks fold-const.c by nearly 500 lines (or by over 4%).

Here are some statistics that show that the potential increase in
memory usage, due to constructing a tree that we then ignore, is
negligable:

Of course, I've been advocating reducing memory usage -- but I think that saving that much code is worth the price, especially given the statistics you posted. If we really do find that we're wasting much memory, then there are other things we can do -- including explicitly freeing the memory in the case that we return NULL_TREE. So, I'd say go for it.


--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]