Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-26 Thread Richard Biener
On Mon, Sep 25, 2017 at 7:14 PM, Prathamesh Kulkarni wrote: > On 18 September 2017 at 15:40, Prathamesh Kulkarni > wrote: >> On 15 September 2017 at 22:09, Marc Glisse wrote: >>> On Fri, 15 Sep 2017, Wilco Dijkstra wrote: >>> Marc Glisse wrote: > The question is whether, having com

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-25 Thread Prathamesh Kulkarni
On 18 September 2017 at 15:40, Prathamesh Kulkarni wrote: > On 15 September 2017 at 22:09, Marc Glisse wrote: >> On Fri, 15 Sep 2017, Wilco Dijkstra wrote: >> >>> Marc Glisse wrote: >>> The question is whether, having computed c=a/b, it is cheaper to test a>>> or c!=0. I think it is usu

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-18 Thread Wilco Dijkstra
Richard Sandiford wrote: > I don't think it's literally always.  Testing the inputs instead of a > multi-use result tends to mean that all three are live at once.  If the > == 0 condition is only one component of a more complex condition that > relies on the result of division regardless, then it'

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-18 Thread Prathamesh Kulkarni
On 15 September 2017 at 22:09, Marc Glisse wrote: > On Fri, 15 Sep 2017, Wilco Dijkstra wrote: > >> Marc Glisse wrote: >> >>> The question is whether, having computed c=a/b, it is cheaper to test a>> or c!=0. >>> I think it is usually the second one, but not for all types on all >>> targets. Altho

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-16 Thread Richard Sandiford
Wilco Dijkstra writes: > Marc Glisse wrote: > >> The question is whether, having computed c=a/b, it is cheaper to test >> a> I think it is usually the second one, but not for all types on all >> targets. Although since >> you mention VRP, it is easier to do further optimizations using the >> infor

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-15 Thread Marc Glisse
On Fri, 15 Sep 2017, Wilco Dijkstra wrote: Marc Glisse wrote: The question is whether, having computed c=a/b, it is cheaper to test a No, a This would indicate that we do not need to check for single-use, makes the patch simpler, thanks. (let's ignore -Os) -- Marc Glisse

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-15 Thread Wilco Dijkstra
Marc Glisse wrote: > The question is whether, having computed c=a/b, it is cheaper to test a c!=0. > I think it is usually the second one, but not for all types on all targets. > Although since > you mention VRP, it is easier to do further optimizations using the > information a

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-15 Thread Jeff Law
On 09/15/2017 09:55 AM, Marc Glisse wrote: > On Fri, 15 Sep 2017, Jeff Law wrote: > >> On 09/15/2017 07:09 AM, Marc Glisse wrote: >>> On Fri, 15 Sep 2017, Prathamesh Kulkarni wrote: >>> >>> +/* (X / Y) == 0 -> X < Y if X, Y are unsigned. */ >>> +(simplify >>> + (eq (trunc_div @0 @1) integer_zero

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-15 Thread Marc Glisse
On Fri, 15 Sep 2017, Jeff Law wrote: On 09/15/2017 07:09 AM, Marc Glisse wrote: On Fri, 15 Sep 2017, Prathamesh Kulkarni wrote: +/* (X / Y) == 0 -> X < Y if X, Y are unsigned. */ +(simplify + (eq (trunc_div @0 @1) integer_zerop) + (if (TYPE_UNSIGNED (TREE_TYPE(@0)) && TYPE_UNSIGNED (TREE_TY

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-15 Thread Jeff Law
On 09/15/2017 07:09 AM, Marc Glisse wrote: > On Fri, 15 Sep 2017, Prathamesh Kulkarni wrote: > > +/* (X / Y) == 0 -> X < Y if X, Y are unsigned. */ > +(simplify > + (eq (trunc_div @0 @1) integer_zerop) > + (if (TYPE_UNSIGNED (TREE_TYPE(@0)) && TYPE_UNSIGNED (TREE_TYPE (@1))) > +(lt @0 @1)))

Re: Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-15 Thread Marc Glisse
On Fri, 15 Sep 2017, Prathamesh Kulkarni wrote: +/* (X / Y) == 0 -> X < Y if X, Y are unsigned. */ +(simplify + (eq (trunc_div @0 @1) integer_zerop) + (if (TYPE_UNSIGNED (TREE_TYPE(@0)) && TYPE_UNSIGNED (TREE_TYPE (@1))) +(lt @0 @1))) + +/* (X / Y) != 0 -> X >= Y, if X, Y are unsigned. */

Transform (x / y) != 0 to x >=y and (x / y) == 0 to x < y if x, y are unsigned

2017-09-15 Thread Prathamesh Kulkarni
Hi, This patch adds the transforms mentioned in $subject. Bootstrap+test in progress on x86_64-unknown-linux-gnu. OK to commit if passes ? Thanks, Prathamesh 2017-09-15 Prathamesh Kulkarni * match.pd ((X / Y) == 0 -> X < Y): New pattern. ((X / Y) != 0 -> X >= Y): Likewise. tes