This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fold bug with multiply and cast and conditional
- From: Roger Sayle <roger at eyesopen dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC ML <gcc at gcc dot gnu dot org>
- Date: Thu, 9 Dec 2004 06:20:09 -0700 (MST)
- Subject: 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
--