On Sat, 13 Jun 2015, Marc Glisse wrote: > They look fine to me. > > > +/* (x & y) + (x ^ y) -> x | y */ > > This also works if you replace + with | or ^. > > > +/* (x | y) - (x ^ y) -> x & y */ > > For symmetry, you probably also want: > (x | y) - (x & y) -> x ^ y > > (they both also work with ^ instead of -)
We already have /* (x & y) ^ (x | y) -> x ^ y */ (simplify (bit_xor:c (bit_and @0 @1) (bit_ior @0 @1)) (bit_xor @0 @1)) but of course with minus it doesn't commutate so it's hard to merge. > > +/* (x & y) + (x | y) -> x + y */ > > Again for symmetry, it seems like this comes with > x + y - (x | y) -> x & y > x + y - (x & y) -> x | y > which seem fine when overflow is undefined or wraps, but not if for instance > it saturates. Can you adjust according to Marcs comment and re-submit? If you like you can do it as followup as well and thus the original patch is ok as well. Thanks, Richard.