This is the mail archive of the gcc-patches@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: [PATCH][4.5] Fix PR31029, missed folding of C - X CMP X


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

-- 
Joseph S. Myers
joseph@codesourcery.com


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