This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fold bug with multiply and cast and conditional


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
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]