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 tree-optimization]: Fix for PR 45397 part 2 of 2


2012/3/15 Richard Guenther <richard.guenther@gmail.com>:
> On Thu, Mar 15, 2012 at 2:09 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> Hi,
>>
>> this is the second part of the patch for this problem. ?It adds some
>> basic simplifications for ==/!=
>> comparisons for eliminating redudant operands.
>>
>> It adds the following patterns:
>> ?-X ==/!= Z - X -> Z ==/!= 0.
>> ?~X ==/!= Z ^ X -> Z ==/!= ~0
>> ?X ==/!= X - Y -> Y == 0
>> ?X ==/!= X + Y -> Y == 0
>> ?X ==/!= X ^ Y -> Y == 0
>> ?(X - Y) ==/!= (Z - Y) -> X ==/!= Z
>> ?(Y - X) ==/!= (Y - Z) -> X ==/!= Z
>> ?(X + Y) ==/!= (X + Z) -> Y ==/!= Z
>> ?(X + Y) ==/!= (Z + X) -> Y ==/!= Z
>> ?(X ^ Y) ==/!= (Z ^ X) -> Y ==/!= Z
>
> Can you re-base this patch to work without the previous one? ?Also
> please coordinate with Andrew. ?Note that all of these(?) simplifications
> are already done by fold_comparison which we could share if you'd split
> out the EXPR_P op0/op1 cases with separated operands/code.
>
> Richard.

Hmm, fold_comparison doesn't do the same thing as it checks for
possible overflow.  This is true for comparisons not being ==/!= or
having operands of none-integral-type.  But for ==/!= with integral
typed arguments  the overflow doesn't matter at all.  And exactly this
is what patch implements here.
This optimization of course is just desired in non-AST form, as we
otherwise loose information in FE.  Therefore I didn't added it to
fold_const.

I can rework the patch so that it works without the other one.

Regards,
Kai


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