[PATCH] Fix PR middle-end/22429, fold building tree which depends on signed overflow

Jeffrey A Law law@redhat.com
Wed Jul 13 19:55:00 GMT 2005


On Tue, 2005-07-12 at 18:54 -0400, Andrew Pinski wrote:
> The problem here is fold (build_range_check) converts
> "-1073741824 <= n && n <= 1073741823" to "n + 1073741824 >= 0" which 
> makes
> depends on signed overflow being defined.  Fold later converts it to
> "n >= -1073741824" by my recent patch which is wrong.  This patch fixes
> the problem by using unsigned types if signed overflow is undefined.
> 
> OK? Bootstrapped and tested on x86_64-pc-linux-gnu with no regressions.
> 
> Thanks,
> Andrew Pinski
> 
> ChangeLog:
> 
> 	* fold-const.c (build_range_check): Use unsigned when signed
> 	overflow is undefined also.  If etype is subtype, make sure that
> 	the subtraction is in the supper type.
I can't convince myself that this patch is either right or wrong.  
Clearly something needs to change, but I'm not entirely sure what.

I'd be more comfortable if someone more familiar with this code
could help out.  IIRC this is mostly Kenner's code, so maybe he
could chime in on this patch too.

jeff




More information about the Gcc-patches mailing list