Re: match.pd: Three new patterns

2015-06-23 Thread Marek Polacek
On Tue, Jun 23, 2015 at 10:22:35AM +0200, Richard Biener wrote: > Who says you can't do bitwise ops on them? I can't see that being > enforced in the GIMPLE checking in tree-cfg.c. Yes, there is no > such thing as a "saturating" bitwise and but bitwise and should > just work fine. > > You can ch

Re: match.pd: Three new patterns

2015-06-23 Thread Richard Biener
On Tue, 23 Jun 2015, Marek Polacek wrote: > On Tue, Jun 23, 2015 at 09:56:33AM +0200, Richard Biener wrote: > > > I think you're right about TYPE_SATURATING so I've dropped that and > > > instead > > > replaced it with TYPE_OVERFLOW_TRAPS. That should do the right thing > > > together with TYPE_

Re: match.pd: Three new patterns

2015-06-23 Thread Marek Polacek
On Tue, Jun 23, 2015 at 09:56:33AM +0200, Richard Biener wrote: > > I think you're right about TYPE_SATURATING so I've dropped that and instead > > replaced it with TYPE_OVERFLOW_TRAPS. That should do the right thing > > together with TYPE_OVERFLOW_SANITIZED. > > Are you sure? The point is that

Re: match.pd: Three new patterns

2015-06-23 Thread Richard Biener
On Mon, 22 Jun 2015, Marek Polacek wrote: > On Fri, Jun 19, 2015 at 05:51:53PM +0200, Marc Glisse wrote: > > On Fri, 19 Jun 2015, Marek Polacek wrote: > > > > >+/* x + y - (x | y) -> x & y */ > > >+(simplify > > >+ (minus (plus @0 @1) (bit_ior @0 @1)) > > >+ (if (!TYPE_OVERFLOW_SANITIZED (type) &

Re: match.pd: Three new patterns

2015-06-22 Thread Marek Polacek
On Fri, Jun 19, 2015 at 05:51:53PM +0200, Marc Glisse wrote: > On Fri, 19 Jun 2015, Marek Polacek wrote: > > >+/* x + y - (x | y) -> x & y */ > >+(simplify > >+ (minus (plus @0 @1) (bit_ior @0 @1)) > >+ (if (!TYPE_OVERFLOW_SANITIZED (type) && !TYPE_SATURATING (type)) > >+ (bit_and @0 @1))) > >+ >

Re: match.pd: Three new patterns

2015-06-22 Thread Richard Biener
On Fri, 19 Jun 2015, Marek Polacek wrote: > On Thu, Jun 18, 2015 at 05:41:18PM +0200, Marek Polacek wrote: > > > 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

Re: match.pd: Three new patterns (and some more)

2015-06-22 Thread Richard Biener
On Thu, 18 Jun 2015, Marek Polacek wrote: > On Tue, Jun 16, 2015 at 03:35:15PM +0200, Richard Biener wrote: > > 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'

Re: match.pd: Three new patterns

2015-06-19 Thread Marc Glisse
On Fri, 19 Jun 2015, Marek Polacek wrote: +/* x + y - (x | y) -> x & y */ +(simplify + (minus (plus @0 @1) (bit_ior @0 @1)) + (if (!TYPE_OVERFLOW_SANITIZED (type) && !TYPE_SATURATING (type)) + (bit_and @0 @1))) + +/* (x + y) - (x & y) -> x | y */ +(simplify + (minus (plus @0 @1) (bit_and @0 @1)

Re: match.pd: Three new patterns

2015-06-19 Thread Marek Polacek
On Thu, Jun 18, 2015 at 05:41:18PM +0200, Marek Polacek wrote: > > 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. > > I'll leave this as a

Re: match.pd: Three new patterns (and some more)

2015-06-18 Thread Marek Polacek
On Tue, Jun 16, 2015 at 03:35:15PM +0200, Richard Biener wrote: > 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. Yeah :(. > > > +/* (x

Re: match.pd: Three new patterns

2015-06-18 Thread Marek Polacek
On Sat, Jun 13, 2015 at 12:05:42PM +0200, Marc Glisse wrote: > They look fine to me. Thanks! > >+/* (x & y) + (x ^ y) -> x | y */ > > This also works if you replace + with | or ^. Done. > >+/* (x | y) - (x ^ y) -> x & y */ > > For symmetry, you probably also want: > (x | y) - (x & y) -> x ^

Re: match.pd: Three new patterns

2015-06-16 Thread Richard Biener
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

Re: match.pd: Three new patterns

2015-06-13 Thread Marc Glisse
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 -) +/* (x & y) + (x | y) -> x + y */ Again fo

match.pd: Three new patterns

2015-06-12 Thread Marek Polacek
This patch brings three new patterns for match.pd. I think these are rare, but it shouldn't hurt to have them. (I suppose you'd be happier if I was moving patterns from fold-const to match.pd. I'll work on that as well.) Given previous discussion, I don't think there's much to say otherwise, but