This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH][4.5] Fix PR31029, missed folding of C - X CMP X
On Sun, 2 Nov 2008, Joseph S. Myers wrote:
> On Sun, 2 Nov 2008, Richard Guenther wrote:
> > * fold-const.c (fold_binary): Fold C - X CMP X.
> This isn't generally valid; 2 - X == X is true for X == 1, for example.
> I don't see a test that the constant is odd (or associated testcases that
> such cases don't get invalidly folded).
> > if (code == EQ_EXPR
> > && !integer_zerop (cst))
> > ! return omit_two_operands (type, boolean_false_node, arg0, arg1);
> It also seems suspicious (preexisting condition) that NE_EXPR &&
> integer_zerop (cst) (i.e. X + 0 != X) isn't handled the same as EQ_EXPR &&
> !integer_zerop, although I suspect fold shouldn't let zero constants get
In general it shouldn't happen, but I have seen it. I'll make sure
to fix both problems.