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
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 2 Nov 2008 17:43:09 +0000 (UTC)
- Subject: Re: [PATCH][4.5] Fix PR31029, missed folding of C - X CMP X
- References: <alpine.LNX.email@example.com>
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
Joseph S. Myers