fold bug with multiply and cast and conditional
Andrew Pinski
pinskia@physics.uc.edu
Thu Dec 9 05:47:00 GMT 2004
On Dec 8, 2004, at 11:03 PM, Roger Sayle wrote:
> Best of luck debugging your problem, wherever it may be :> My initial
> guess would be that your combiner is not correctly casting the types of
> the operands of the multiplication to the appropriate/result type.
> Just a guess, but this would explain why you can't reproduce it with
> any of GCC's language front-ends, which correctly preserve tree type
> safety.
Sorry about misattributing this problem to your patch. I should looked
into the problem a little further.
It was due to the wrong type but not by my tree combiner. The
bug is in fold_binary_op_with_conditional_arg still. We take
the type of the conditional to make true/false_value instead of
using the type of the outer operation so we get a miss-matched type.
It also explains why I cannot reproduce it with the front-ends (well I
only tried the C based ones) but the front-ends do not produce a
straight up conversion to int from a condition, but instead they
(really convert) creates a COND_EXPR which means we don't hit this
part of the code also.
This is the patch which I am testing which should fix the bug, this is a
regression in a sense from 2.95.3 which did not have
fold_binary_op_with_conditional_arg.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.482
diff -u -p -r1.482 fold-const.c
--- fold-const.c 30 Nov 2004 20:33:34 -0000 1.482
+++ fold-const.c 9 Dec 2004 05:29:08 -0000
@@ -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);
}
if (lhs == 0)
Thanks,
Andrew Pinski
More information about the Gcc
mailing list