[PATCH] Fix PR middle-end/14490

Jeffrey A Law law@redhat.com
Sat Jul 2 14:42:00 GMT 2005


On Thu, 2005-06-30 at 15:10 -0400, Andrew Pinski wrote:
> This fixes a missed optimization which is not done on the tree level or 
> RTL level.
> We should be able to fold "x -+ CONST1 > CONST2" to "x > CONST2 +- 
> CONST1" if the
> addition/subtraction does not overflow.  This can only be done for 
> signed types
> when wrapping is undefined.
> 
> I also found a latent bug in handing the return value of
> fold_to_nonsharp_ineq_using_bound in that if we get back the same tree 
> (not same
> memory location but represents the same tree) back, we end up in an 
> infinite loop.
> This happens as we generate the following to fold in that function:
> "a - 1 >= 0" (to a > 0) but originally we had "a > 0" so we end up 
> trying to do
> the same fold over and over.
> 
> OK? Tested on powerpc-darwin with no regressions.
> 
> Thanks,
> Andrew Pinski
> 
> ChangeLog:
> 
> 	* fold-const.c (fold_binary): Handle the return value of
> 	fold_to_nonsharp_ineq_using_bound if we get back the same operand back.
> 	Implement "X +- C1 CMP C2" folding to "X CMP C2 -+ C1".
The updated version (which does not apply this transformation to FP
values) is OK.

Thanks,
jeff




More information about the Gcc-patches mailing list