RFC: PR 19650
Dale Johannesen
dalej@apple.com
Sat Jan 29 01:31:00 GMT 2005
On Jan 28, 2005, at 12:05 PM, Roger Sayle wrote:
> I think the best route out of this hole is to pass an additional
> "tree arg_type" parameter to the fold_binary_op_with_conditional_arg
> function. At both call sites in fold, this is simply the value
> "TREE_TYPE (TREE_OPERAND (t, 0))", i.e. the unstripped type of the
> first operand.
Like so, I think you mean (not exactly what you said):
@@ -6466,7 +6474,8 @@ fold (tree expr)
if (TREE_CODE (arg0) == COND_EXPR || COMPARISON_CLASS_P (arg0))
{
tem = fold_binary_op_with_conditional_arg (code, type, arg0,
arg1,
-
/*cond_first_p=*/1);
+ /*cond_first_p=*/1,
+ TREE_TYPE
(TREE_OPERAND (t, 0)));
if (tem != NULL_TREE)
return tem;
}
@@ -6474,7 +6483,8 @@ fold (tree expr)
if (TREE_CODE (arg1) == COND_EXPR || COMPARISON_CLASS_P (arg1))
{
tem = fold_binary_op_with_conditional_arg (code, type, arg1,
arg0,
-
/*cond_first_p=*/0);
+ /*cond_first_p=*/0,
+ TREE_TYPE
(TREE_OPERAND (t, 1)));
if (tem != NULL_TREE)
return tem;
}
> Then inside the function itself we cast "arg",
> "true_value" and "false_value" to this "arg_type", before using them
> as operands to build a tree with code CODE and result type TYPE.
>
>
> + arg = fold_convert (arg_type, arg);
> if (lhs == 0)
> + {
> + true_value = fold_convert (arg_type, true_value);
> lhs = fold (cond_first_p ? build2 (code, type, true_value, arg)
> : build2 (code, type, arg, true_value));
> }
> if (rhs == 0)
> + {
> + false_value = fold_convert (arg_type, false_value);
> rhs = fold (cond_first_p ? build2 (code, type, false_value, arg)
> : build2 (code, type, arg,
> false_value));
> + }
That seems to solve the bootstrap problem and the original failure.
I'll
run it through more testing. Thanks.
More information about the Gcc
mailing list