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] Fix PR middle-end/14490


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



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