fold bug with multiply and cast and conditional

Roger Sayle roger@eyesopen.com
Thu Dec 9 14:41:00 GMT 2004


On Thu, 9 Dec 2004, Andrew Pinski wrote:
> @@ -5392,10 +5392,9 @@ fold_binary_op_with_conditional_arg (enu
>       }
>     else
>       {
> -      tree testtype = TREE_TYPE (cond);
>         test = cond;
> -      true_value = constant_boolean_node (true, testtype);
> -      false_value = constant_boolean_node (false, testtype);
> +      true_value = constant_boolean_node (true, type);
> +      false_value = constant_boolean_node (false, type);
>       }
>

Hmm.  I guess this is Ok if we can't trust that "cond" has type
"type".  If you're going to make this change, might I also then
recommend the symmetrical change to not assume the other operand
"arg" is of type "type" either.  i.e. add the line

	arg = fold_convert (type, arg);

either just after the "if (!TREE_CONSTANT (arg))" test, or just
before the "if (lhs == 0)" test.  We know "arg" is a constant,
so this just ensures it has the right type, and shouldn't obfuscate
the trees we generate.


Post the full patch to gcc-patches with a ChangeLog after you've
bootstrapped and regression tested it, and I'll take a look.

Roger
--



More information about the Gcc mailing list