Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-10-06 Thread Richard Biener
On Thu, Oct 1, 2015 at 10:20 AM, Michael Collison wrote: > Marc, > > Ah I did misunderstand you. Patch with match.pd formatting fix. Ok if bootstrap/regtest passes. Thanks, Richard. > On 10/01/2015 01:05 AM, Marc Glisse wrote: >> >> On Thu, 1 Oct 2015, Michael Collison wrote: >> >>> ChangeLog f

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-10-01 Thread Michael Collison
Marc, Ah I did misunderstand you. Patch with match.pd formatting fix. On 10/01/2015 01:05 AM, Marc Glisse wrote: On Thu, 1 Oct 2015, Michael Collison wrote: ChangeLog formatting and test case fixed. Oups, sorry for the lack of precision, but I meant indenting the code in match.pd, I hadn't

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-10-01 Thread Marc Glisse
On Thu, 1 Oct 2015, Michael Collison wrote: ChangeLog formatting and test case fixed. Oups, sorry for the lack of precision, but I meant indenting the code in match.pd, I hadn't even looked at the ChangeLog. -- Marc Glisse

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-10-01 Thread Michael Collison
ChangeLog formatting and test case fixed. On 09/30/2015 12:30 PM, Marc Glisse wrote: On Fri, 18 Sep 2015, Marc Glisse wrote: +(bit_and:c (op @0 @1) (op @0 @2)) :c seems useless here. On the other hand, it might make sense to use op:s since this is mostly useful if it removes the 2 original

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-30 Thread Marc Glisse
On Wed, 30 Sep 2015, Michael Collison wrote: Richard and Marc, Latest patch attached which incorporates all comments. 2015-09-30 Michael Collison Andrew Pinski * match.pd ((x < y) && (x < z) -> x < min (y,z), (x > y) and (x > z) -> x > max (y,z)) * testsuite/gcc.dg/tree-ssa

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-30 Thread Michael Collison
Richard and Marc, Latest patch attached which incorporates all comments. 2015-09-30 Michael Collison Andrew Pinski * match.pd ((x < y) && (x < z) -> x < min (y,z), (x > y) and (x > z) -> x > max (y,z)) * testsuite/gcc.dg/tree-ssa/minmax-loopend.c: New test. On 09/30/2015

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-30 Thread Marc Glisse
On Fri, 18 Sep 2015, Marc Glisse wrote: +(bit_and:c (op @0 @1) (op @0 @2)) :c seems useless here. On the other hand, it might make sense to use op:s since this is mostly useful if it removes the 2 original comparisons. As I was saying, :c is useless. (x:c y z) is replaced by two copies of the

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-30 Thread Michael Collison
The current patch is attached. 2015-09-30 Michael Collison Andrew Pinski * match.pd ((x < y) && (x < z) -> x < min (y,z), (x > y) and (x > z) -> x > max (y,z)) * testsuite/gcc.dg/tree-ssa/minmax-loopend.c: New test. On 09/30/2015 01:14 AM, Richard Biener wrote: On Wed

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-30 Thread Richard Biener
On Wed, Sep 30, 2015 at 9:29 AM, Michael Collison wrote: > Richard and Marc, > > What is ':s'? I don't see any documentation for it. So you would like me to > remove :c and add :s? There is documentation for both in the internals manual. I don't have enough context to say whether you should remo

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-30 Thread Michael Collison
Richard and Marc, What is ':s'? I don't see any documentation for it. So you would like me to remove :c and add :s? On 09/18/2015 02:23 AM, Richard Biener wrote: On Fri, Sep 18, 2015 at 9:38 AM, Marc Glisse wrote: Just a couple extra points. We can end up with a mix of < and >, which might

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-18 Thread Marc Glisse
On Fri, 18 Sep 2015, Michael Collison wrote: Can you elaborate on merging the patterns using 'ext' as mentioned in your post? I don't see any documentation or examples. https://gcc.gnu.org/onlinedocs/gccint/The-Language.html "for" lets you iterate on several variables at the same time. For in

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-18 Thread Michael Collison
Marc, Can you elaborate on merging the patterns using 'ext' as mentioned in your post? I don't see any documentation or examples. On 09/18/2015 12:00 AM, Marc Glisse wrote: On Thu, 17 Sep 2015, Michael Collison wrote: Here is the the patch modified with test cases for MIN_EXPR and MAX_EXPR

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-18 Thread Richard Biener
On Fri, Sep 18, 2015 at 9:38 AM, Marc Glisse wrote: > Just a couple extra points. We can end up with a mix of < and >, which might > prevent from matching: > > _3 = b_1(D) > a_2(D); > _5 = a_2(D) < c_4(D); > _8 = _3 & _5; > > Just like with &, we could also transform: > x < y | x < z --->

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-18 Thread Marc Glisse
Just a couple extra points. We can end up with a mix of < and >, which might prevent from matching: _3 = b_1(D) > a_2(D); _5 = a_2(D) < c_4(D); _8 = _3 & _5; Just like with &, we could also transform: x < y | x < z ---> x < max(y, z) (but maybe wait to make sure reviewers are ok with t

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-18 Thread Marc Glisse
On Thu, 17 Sep 2015, Michael Collison wrote: Here is the the patch modified with test cases for MIN_EXPR and MAX_EXPR expressions. I need some assistance; this test case will fail on targets that don't have support for MIN/MAX such as 68k. Is there any way to remedy this short of enumerating w

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-09-17 Thread Michael Collison
On 07/31/2015 11:27 AM, Jeff Law wrote: On 07/31/2015 12:18 PM, Michael Collison wrote: Hi Jeff, Yes I will create a test case. I'm not quite sure what to check for even in the machine dependent test case. It's quite possible for the instructions that are generated to change over time. I think

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-08-05 Thread Jeff Law
On 08/05/2015 10:07 AM, Alan Lawrence wrote: Richard Biener wrote: Furthermore it doesn't work for three such ops which would require an additional pattern like (simplfiy (bit_and:c (op @0 (min @1 @2)) (op @0 @3)) (op @0 (min (min @1 @2) @3 if that's profitable? Shouldn't that be j

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-08-05 Thread Alan Lawrence
Richard Biener wrote: Furthermore it doesn't work for three such ops which would require an additional pattern like (simplfiy (bit_and:c (op @0 (min @1 @2)) (op @0 @3)) (op @0 (min (min @1 @2) @3 if that's profitable? Shouldn't that be just a case of binding @1 in the original patte

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-08-03 Thread Richard Biener
On Fri, Jul 31, 2015 at 8:27 PM, Jeff Law wrote: > On 07/31/2015 12:18 PM, Michael Collison wrote: >> >> Hi Jeff, >> >> Yes I will create a test case. I'm not quite sure what to check for even >> in the machine dependent test case. It's quite possible for the >> instructions that are generated to

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-31 Thread Jeff Law
On 07/31/2015 12:18 PM, Michael Collison wrote: Hi Jeff, Yes I will create a test case. I'm not quite sure what to check for even in the machine dependent test case. It's quite possible for the instructions that are generated to change over time. I think we're going to want to look at the gimple

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-31 Thread Michael Collison
Hi Jeff, Yes I will create a test case. I'm not quite sure what to check for even in the machine dependent test case. It's quite possible for the instructions that are generated to change over time. On 7/31/2015 9:20 AM, Jeff Law wrote: On 07/28/2015 01:41 AM, Richard Biener wrote: The abo

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-31 Thread Jeff Law
On 07/28/2015 01:41 AM, Richard Biener wrote: The above case is a corner case I think - the number of && you can change into (multiple) MIN/MAX is unbound but we might only care about the case where there will be one MIN/MAX operation. I suspect that's going to be the most important/common case

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-29 Thread Michael Collison
Richard and Jeff, Any conclusion to this discussion? Is this okay in match.pd or would you like to see it implemented elsewhere? On 7/28/2015 12:41 AM, Richard Biener wrote: On Mon, Jul 27, 2015 at 6:20 PM, Jeff Law wrote: On 07/27/2015 03:25 AM, Richard Biener wrote: On Mon, Jul 27, 2015

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-28 Thread Richard Biener
On Mon, Jul 27, 2015 at 6:20 PM, Jeff Law wrote: > On 07/27/2015 03:25 AM, Richard Biener wrote: >> >> On Mon, Jul 27, 2015 at 5:41 AM, Michael Collison >> wrote: >>> >>> This patch is designed to optimize end of loop conditions involving of >>> the >>> form >>> i < x && i < y into i < min (x,

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-27 Thread Jeff Law
On 07/27/2015 03:25 AM, Richard Biener wrote: On Mon, Jul 27, 2015 at 5:41 AM, Michael Collison wrote: This patch is designed to optimize end of loop conditions involving of the form i < x && i < y into i < min (x, y). Loop condition involving '>' are handled similarly using max(x,y). As an e

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-27 Thread Richard Biener
On Mon, Jul 27, 2015 at 5:41 AM, Michael Collison wrote: > This patch is designed to optimize end of loop conditions involving of the > form > i < x && i < y into i < min (x, y). Loop condition involving '>' are > handled similarly using max(x,y). > As an example: > > #define N 1024 > > int a[N]

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-26 Thread Bin.Cheng
On Mon, Jul 27, 2015 at 12:23 PM, Bin.Cheng wrote: > On Mon, Jul 27, 2015 at 11:41 AM, Michael Collison > wrote: >> This patch is designed to optimize end of loop conditions involving of the >> form >> i < x && i < y into i < min (x, y). Loop condition involving '>' are >> handled similarly usin

Re: [PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-26 Thread Bin.Cheng
On Mon, Jul 27, 2015 at 11:41 AM, Michael Collison wrote: > This patch is designed to optimize end of loop conditions involving of the > form > i < x && i < y into i < min (x, y). Loop condition involving '>' are > handled similarly using max(x,y). > As an example: > > #define N 1024 > > int a[N

[PATCH] Optimize certain end of loop conditions into min/max operation

2015-07-26 Thread Michael Collison
This patch is designed to optimize end of loop conditions involving of the form i < x && i < y into i < min (x, y). Loop condition involving '>' are handled similarly using max(x,y). As an example: #define N 1024 int a[N], b[N], c[N]; void add (unsignedint m, unsignedint n) { unsignedin