Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Richard Biener
On Tue, 30 Jun 2015, Marek Polacek wrote: > On Tue, Jun 30, 2015 at 03:59:23PM +0200, Richard Biener wrote: > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > > On Tue, Jun 30, 2015 at 03:13:14PM +0200, Richard Biener wrote: > > > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > > > > > >

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marek Polacek
On Tue, Jun 30, 2015 at 03:59:23PM +0200, Richard Biener wrote: > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > On Tue, Jun 30, 2015 at 03:13:14PM +0200, Richard Biener wrote: > > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > > > > On Tue, Jun 30, 2015 at 02:47:49PM +0200, Richard Biener

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Richard Biener
On Tue, 30 Jun 2015, Marek Polacek wrote: > On Tue, Jun 30, 2015 at 03:13:14PM +0200, Richard Biener wrote: > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > > On Tue, Jun 30, 2015 at 02:47:49PM +0200, Richard Biener wrote: > > > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > > > > > >

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marek Polacek
On Tue, Jun 30, 2015 at 03:13:14PM +0200, Richard Biener wrote: > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > On Tue, Jun 30, 2015 at 02:47:49PM +0200, Richard Biener wrote: > > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > > > > On Tue, Jun 30, 2015 at 01:39:29PM +0200, Marc Glisse wro

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Richard Biener
On Tue, 30 Jun 2015, Marek Polacek wrote: > On Tue, Jun 30, 2015 at 02:47:49PM +0200, Richard Biener wrote: > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > > On Tue, Jun 30, 2015 at 01:39:29PM +0200, Marc Glisse wrote: > > > > Does my suggestion to "build the all_ones constant in TREE_TYPE

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marek Polacek
On Tue, Jun 30, 2015 at 02:47:49PM +0200, Richard Biener wrote: > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > On Tue, Jun 30, 2015 at 01:39:29PM +0200, Marc Glisse wrote: > > > Does my suggestion to "build the all_ones constant in TREE_TYPE (@0) and > > > convert that to type" help for that? >

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Richard Biener
On Tue, 30 Jun 2015, Marek Polacek wrote: > On Tue, Jun 30, 2015 at 01:39:29PM +0200, Marc Glisse wrote: > > Does my suggestion to "build the all_ones constant in TREE_TYPE (@0) and > > convert that to type" help for that? > > It appears to work, but it seems weird to me to create a integer const

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marek Polacek
On Tue, Jun 30, 2015 at 01:39:29PM +0200, Marc Glisse wrote: > Does my suggestion to "build the all_ones constant in TREE_TYPE (@0) and > convert that to type" help for that? It appears to work, but it seems weird to me to create a integer constant in one type and then immediately cast it to anoth

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marc Glisse
On Tue, 30 Jun 2015, Marek Polacek wrote: I put some more converts into the pattern, but then it's turned out that I also need the tree_nop_conversion_p (otherwise we'd regress binop-notor2.c that uses booleans). I don't really see why removing tree_nop_conversion_p would regress anything (tho

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marek Polacek
On Tue, Jun 30, 2015 at 12:22:57PM +0200, Bernhard Reutner-Fischer wrote: > >+unsigned int > >+fn3 (unsigned int x) > >+{ > >+ return ~x | x; > >+} > >+ > >+unsigned int > >+fn4 (unsigned int x) > >+{ > >+ return ~x | x; > >+} > > What's the difference between fn3 and fn4? Oops, fixed. 2015-06

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Richard Biener
On Tue, 30 Jun 2015, Marek Polacek wrote: > On Tue, Jun 30, 2015 at 11:08:35AM +0200, Marc Glisse wrote: > > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > > >This moves a simple optimization. Here it's plain to see how :c > > >removes the need to duplicate code to handle commutativity. > > >

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marek Polacek
On Tue, Jun 30, 2015 at 11:08:35AM +0200, Marc Glisse wrote: > On Tue, 30 Jun 2015, Marek Polacek wrote: > > >This moves a simple optimization. Here it's plain to see how :c > >removes the need to duplicate code to handle commutativity. > > Note that the same transformation would work for plus a

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Bernhard Reutner-Fischer
On June 30, 2015 10:46:21 AM GMT+02:00, Marek Polacek wrote: >--- gcc/testsuite/gcc.dg/fold-ior-2.c >+++ gcc/testsuite/gcc.dg/fold-ior-2.c >@@ -0,0 +1,47 @@ >+/* { dg-do compile } */ >+/* { dg-options "-O -fdump-tree-cddce1" } */ >+ >+int >+fn1 (int x) >+{ >+ return ~x | x; >+} >+ >+int >+fn2 (

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Richard Biener
On Tue, 30 Jun 2015, Marc Glisse wrote: > On Tue, 30 Jun 2015, Marek Polacek wrote: > > > This moves a simple optimization. Here it's plain to see how :c > > removes the need to duplicate code to handle commutativity. > > Note that the same transformation would work for plus and xor. > > > I pu

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marc Glisse
On Tue, 30 Jun 2015, Marek Polacek wrote: This moves a simple optimization. Here it's plain to see how :c removes the need to duplicate code to handle commutativity. Note that the same transformation would work for plus and xor. I put some more converts into the pattern, but then it's turne

Re: [PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Richard Biener
On Tue, 30 Jun 2015, Marek Polacek wrote: > This moves a simple optimization. Here it's plain to see how :c > removes the need to duplicate code to handle commutativity. > > I put some more converts into the pattern, but then it's turned > out that I also need the tree_nop_conversion_p (otherwis

[PATCH] Move ~X | X -> -1 folding

2015-06-30 Thread Marek Polacek
This moves a simple optimization. Here it's plain to see how :c removes the need to duplicate code to handle commutativity. I put some more converts into the pattern, but then it's turned out that I also need the tree_nop_conversion_p (otherwise we'd regress binop-notor2.c that uses booleans). I