This is the mail archive of the
mailing list for the GCC project.
Re: [patch] fold-const.c (fold): Clean up use of variable "t".
- From: Roger Sayle <roger at eyesopen dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Mar 2004 06:25:48 -0700 (MST)
- Subject: Re: [patch] fold-const.c (fold): Clean up use of variable "t".
On Fri, 19 Mar 2004, Kazu Hirata wrote:
> Now, some people may not like to declare a variable whose name is also
> used in an outer scope, but IMHO that would be a separate problem as
> addressing this problem would unnecessarily complicate the patch.
> 2004-03-19 Kazu Hirata <email@example.com>
> * fold-const.c (fold): Declare "t" locally if needed
> temporarily. Remove "orig_t".
I really like this clean-up, but as Richard Kenner has suggested
the shadowing of "t" can be confusing, and without "shrink-wrapping"
can lead to larger stack frames for fold, which is often recursive.
Fortunately, most of the cases that you clean-up, require very short
life-times/scopes for the new local "t". In these cases, I'd recommend
using the fold-scope "tem" variable.
if (REAL_VALUE_ISNAN (cst)
&& ! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1))))
- t = (code == NE_EXPR) ? integer_one_node : integer_zero_node;
+ tem =
+ (code == NE_EXPR) ? integer_one_node : integer_zero_node;
return omit_one_operand (type, fold_convert (type, tem),
i.e. use "tem" rather than "tree t".
However, I really like the concept of making "t" const, and completely
removing "orig_t". For the remaining difficult cases you might consider
a recursive call to fold with the modified t, or alternatively you could
rename all uses of "t" between its modification and the next "return t".
Once this is done, I think we might be able to remove the fold_1 wrapper
used by --enable-checking=fold, as we should be able guarantee the input
tree is immutable (i.e. that fold is nondestructive).