[ast-optimizer-branch] PATCH to &&, ++ and return
Jason Merrill
jason@redhat.com
Sun Jun 9 22:28:00 GMT 2002
The bottom ChangeLog bits are infrastructure for the upper three, which are
independent of one another, but I'm checking them in together because I'm
lazy.
get_initialized_tmp_var creates a new initialized temp, so callers don't
have to deal with building up, simplifying and adding a MODIFY_EXPR.
simplify_expr_common now takes a NULL post_p argument; in this case, if the
expression being simplified has post-effects, the result will be copied
to a temp and the post-effects emitted before returning. This is used in
simplify_return_stmt here, and will be used in the loop nodes in a later
patch.
I've changed simplify_return_stmt to accept an RHS, while the grammar says
it should only accept a VAL. The reason for this is to avoid an extra temp
on code like
struct A f ();
struct A g ()
{
return f ();
}
Here, if we require a VAL, we need to copy the returned struct into our
stack frame before returning it. This can be slow, depending on the size
of A. And a return statement is already represented with a MODIFY_EXPR,
anyway...
I've fixed simplify_self_mod_expr so that an expression like (*f())++ only
calls f once. This fixes gcc.dg/20020426-2.c.
I've fixed simplify_boolean_expr so that the temp used to keep track of the
current state has the appropriate boolean type (int, in C); previously it
would get the type of the && expression, which could be an arbitrary type.
In gcc.c-torture/compile/980706-1.c there is a && expression which ends up
having long long type. I've also reduced the number of comparisons we
build; we know that T is a boolean value, we don't need to keep comparing
it to zero.
Booted and tested i686-pc-linux-gnu. Also fixes gcc.dg/uninit-A.c, though
that may be transient.
2002-06-10 Jason Merrill <jason@redhat.com>
* c-simplify.c (simplify_boolean_expr): Avoid redundant tests.
Give the temp the appropriate type for a boolean value, and
reconvert at the end.
* c-simplify.c (simplify_self_mod_expr): Don't duplicate side-effects.
* c-simplify.c (simplify_return_stmt): Accept a SIMPLE rhs.
Just hand off to simplify_expr.
* c-simplify.c (get_initialized_tmp_var): New fn.
(simplify_expr_common): Use it. Handle post-effects internally if
POST_P is NULL.
(is_simple_tmp_var): Rename from simple_tmp_var_p.
* tree-simple.h: Adjust.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-patch
Size: 13758 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020609/80339b00/attachment.bin>
More information about the Gcc-patches
mailing list