This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR middle-end/14490
- From: Jeffrey A Law <law at redhat dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 02 Jul 2005 08:42:30 -0600
- Subject: Re: [PATCH] Fix PR middle-end/14490
- References: <f5de2762e0ef737afe7f077f13f82602@physics.uc.edu>
- Reply-to: law at redhat dot com
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