Re: [PATCH] match.pd: optimize unsigned mul overflow check

2016-05-30 Thread Alexander Monakov
On Sun, 29 May 2016, Marc Glisse wrote: > On Sat, 28 May 2016, Alexander Monakov wrote: > > For unsigned A, B, 'A > -1 / B' is a nice predicate for checking whether > > 'A*B' > > overflows (or 'B && A > -1 / B' if B may be zero). Let's optimize it to an > > invocation of __builtin_mul_overflow to

Re: [PATCH] match.pd: optimize unsigned mul overflow check

2016-05-30 Thread Richard Biener
On Mon, May 30, 2016 at 1:15 PM, Jakub Jelinek wrote: > On Mon, May 30, 2016 at 12:55:22PM +0200, Richard Biener wrote: >> CCing Jakub who wrote the tree-ssa-math-opts.c code last year. I remember we >> discussed using match.pd but ended up with not doing it there but I >> don't remember >> the e

Re: [PATCH] match.pd: optimize unsigned mul overflow check

2016-05-30 Thread Jakub Jelinek
On Mon, May 30, 2016 at 12:55:22PM +0200, Richard Biener wrote: > CCing Jakub who wrote the tree-ssa-math-opts.c code last year. I remember we > discussed using match.pd but ended up with not doing it there but I > don't remember > the exact reason. richi: does match.pd support turning non-call

Re: [PATCH] match.pd: optimize unsigned mul overflow check

2016-05-30 Thread Richard Biener
On Mon, May 30, 2016 at 9:14 AM, Alexander Monakov wrote: > On Sun, 29 May 2016, Marc Glisse wrote: >> On Sat, 28 May 2016, Alexander Monakov wrote: >> >> > For unsigned A, B, 'A > -1 / B' is a nice predicate for checking whether >> > 'A*B' >> > overflows (or 'B && A > -1 / B' if B may be zero).

Re: [PATCH] match.pd: optimize unsigned mul overflow check

2016-05-30 Thread Alexander Monakov
On Sun, 29 May 2016, Marc Glisse wrote: > On Sat, 28 May 2016, Alexander Monakov wrote: > > > For unsigned A, B, 'A > -1 / B' is a nice predicate for checking whether > > 'A*B' > > overflows (or 'B && A > -1 / B' if B may be zero). Let's optimize it to an > > invocation of __builtin_mul_overflow

Re: [PATCH] match.pd: optimize unsigned mul overflow check

2016-05-29 Thread Marc Glisse
On Sat, 28 May 2016, Alexander Monakov wrote: For unsigned A, B, 'A > -1 / B' is a nice predicate for checking whether 'A*B' overflows (or 'B && A > -1 / B' if B may be zero). Let's optimize it to an invocation of __builtin_mul_overflow to avoid the divide operation. I forgot to ask earlier:

Re: [PATCH] match.pd: optimize unsigned mul overflow check

2016-05-29 Thread Marc Glisse
On Sat, 28 May 2016, Alexander Monakov wrote: For unsigned A, B, 'A > -1 / B' is a nice predicate for checking whether 'A*B' overflows (or 'B && A > -1 / B' if B may be zero). Let's optimize it to an invocation of __builtin_mul_overflow to avoid the divide operation. Hmm, that division by zer

[PATCH] match.pd: optimize unsigned mul overflow check

2016-05-28 Thread Alexander Monakov
Hello, For unsigned A, B, 'A > -1 / B' is a nice predicate for checking whether 'A*B' overflows (or 'B && A > -1 / B' if B may be zero). Let's optimize it to an invocation of __builtin_mul_overflow to avoid the divide operation. The following patch implements that as a match.pd transformation.