[PATCH] Simplify builtins when result ignored.
Sun Apr 13 18:30:00 GMT 2003
Roger Sayle <email@example.com> writes:
> This patch avoids expanding built-in functions for strlen, memcmp,
> strcmp, strncmp and similar functions when its known the result is
> ignored and the pointer arguments are not volatile. This reduces
> the amount of initial RTL we generate and the usual good things.
> These calls are eliminated by life analysis in the RTL optimizers
> (if the "pure" attribute machinery is working :), but less useless
> RTL means a smaller memory foot-print, less fragmentation, less
> work for the early RTL optimizers, etc...
This is a good idea, but can't you make it a general optimization done
for all calls to functions with attribute pure or const, rather than
applying it individually in all these expanders?
Also it might be a good idea to do it at "fold" time as well, which
would avoid even more work.
> Whilst there, I also added the expansion-time optimization of strlen
> for constant strings. This is typically handled by "fold", but
> performing the check in expand_builtin_strlen provides both a good
> pedagogical example and reduces the dependencies between GCC passes.
> For example, if tree-SSA or a language front-end didn't call "fold"
> on an expression before RTL expansion.
This piece is approved for mainline -- but only as a separate patch
from the other changes.
More information about the Gcc-patches