This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Incomplete TREE_CONSTANT-propagation in build() ?
On Tue, 4 Nov 2003, Ziemowit Laski wrote:
> Well, I was thinking in terms of gcc internals rather than standards.
> (I neither object to nor understand what the standars says in this case,
> but that's an orthogonal matter.)
TREE_CONSTANT is used as a weird hybrid of GCC-internal-constantness and
standard-constantness. It is entirely inadequate for implementing the C99
standard definition of constant expressions (for that, expressions need
*several* flags to be kept track of for each subexpression: certain types
of subexpressions prevent the whole containing expression from being
constant (or a particular kind of constant) while others don't when in
unevaluated subexpressions), but until the C front end has such several
flags I suspect changing TREE_CONSTANT would break cases where the
handling of constant expressions isn't already broken.
On the separate matter of delaying folding these expressions, I suspect
delaying all folding beyond that actually required for integer constant
expressions, until a full expression is obtained, would be a good idea.
It might fix bugs where folding interacts with constraint checking, avoid
the various bugs where -pedantic disables optimizations because of this
(since the constraints would all have been checked before folding, so
-pedantic could be as irrelevant to folding as it ought to be), and maybe
even (this would require benchmarking) speed up the compiler: less work
done all the time in the middle of parsing could mean parser tables go out
of cache less frequently.
--
Joseph S. Myers
jsm@polyomino.org.uk