On Thu, Mar 15, 2012 at 2:46 PM, Kai Tietz <ktiet...@googlemail.com> wrote: > 2012/3/15 Richard Guenther <richard.guent...@gmail.com>: >> On Thu, Mar 15, 2012 at 2:09 PM, Kai Tietz <ktiet...@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.
fold_comparison does not check for overflow for ==/!=. > 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. Which pieces are not already in fold-const btw? forwprop already re-constructs trees for the defs of the lhs/rhs of a comparison. Richard. > I can rework the patch so that it works without the other one. > > Regards, > Kai