Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-10-22 Thread Alan Hayward
On 22/10/2015 15:15, "Alan Lawrence" wrote: >Just one very small point... > >On 19/10/15 09:17, Alan Hayward wrote: > > > - if (check_reduction > > - && (!commutative_tree_code (code) || !associative_tree_code >(code))) > > + if (check_reduction) > > { > > -

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-10-22 Thread Alan Lawrence
Just one very small point... On 19/10/15 09:17, Alan Hayward wrote: > - if (check_reduction > - && (!commutative_tree_code (code) || !associative_tree_code (code))) > + if (check_reduction) > { > - if (dump_enabled_p ()) > -report_vect_op (MSG_MISSED_OPTIMIZATION,

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-10-21 Thread Richard Biener
On Mon, Oct 19, 2015 at 10:17 AM, Alan Hayward wrote: > > >>On 30/09/2015 13:45, "Richard Biener" wrote: >> >>>On Wed, Sep 23, 2015 at 5:51 PM, Alan Hayward >>>wrote: On 18/09/2015 14:53, "Alan Hayward"

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-10-01 Thread Alan Hayward
On 30/09/2015 13:45, "Richard Biener" wrote: >On Wed, Sep 23, 2015 at 5:51 PM, Alan Hayward >wrote: >> >> >> On 18/09/2015 14:53, "Alan Hayward" wrote: >> >>> >>> >>>On 18/09/2015 14:26, "Alan Lawrence"

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-30 Thread Richard Biener
On Wed, Sep 23, 2015 at 5:51 PM, Alan Hayward wrote: > > > On 18/09/2015 14:53, "Alan Hayward" wrote: > >> >> >>On 18/09/2015 14:26, "Alan Lawrence" wrote: >> >>>On 18/09/15 13:17, Richard Biener wrote: Ok, I see.

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-23 Thread Alan Hayward
On 18/09/2015 14:53, "Alan Hayward" wrote: > > >On 18/09/2015 14:26, "Alan Lawrence" wrote: > >>On 18/09/15 13:17, Richard Biener wrote: >>> >>> Ok, I see. >>> >>> That this case is already vectorized is because it implements MAX_EXPR, >>>

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-18 Thread Richard Biener
On Tue, Sep 15, 2015 at 5:32 PM, Alan Hayward wrote: > > > On 15/09/2015 13:09, "Richard Biener" wrote: > >> >>Now comments on the patch itself. >> >>+ if (code == COND_EXPR) >>+ *v_reduc_type = COND_REDUCTION; >> >>so why not simply

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-18 Thread Alan Lawrence
On 18/09/15 13:17, Richard Biener wrote: Ok, I see. That this case is already vectorized is because it implements MAX_EXPR, modifying it slightly to int foo (int *a) { int val = 0; for (int i = 0; i < 1024; ++i) if (a[i] > val) val = a[i] + 1; return val; } makes it no

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-18 Thread Alan Hayward
On 18/09/2015 14:26, "Alan Lawrence" wrote: >On 18/09/15 13:17, Richard Biener wrote: >> >> Ok, I see. >> >> That this case is already vectorized is because it implements MAX_EXPR, >> modifying it slightly to >> >> int foo (int *a) >> { >>int val = 0; >>for (int i

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-15 Thread Richard Biener
On Fri, Sep 11, 2015 at 6:29 PM, Ramana Radhakrishnan wrote: > Saying that all reductions have equivalent performance is unlikely to be true for many platforms. On PowerPC, for example, a PLUS reduction has very different cost from a MAX

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-15 Thread Richard Biener
On Thu, Sep 10, 2015 at 4:51 PM, Alan Hayward wrote: > Hi, > This patch (attached) adds support for vectorizing conditional expressions > (PR 65947), for example: > > int condition_reduction (int *a, int min_v) > { > int last = 0; > for (int i = 0; i < N; i++) > if

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-15 Thread Richard Biener
On Thu, Sep 10, 2015 at 4:51 PM, Alan Hayward wrote: > Hi, > This patch (attached) adds support for vectorizing conditional expressions > (PR 65947), for example: > > int condition_reduction (int *a, int min_v) > { > int last = 0; > for (int i = 0; i < N; i++) > if

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-15 Thread Alan Hayward
On 15/09/2015 13:09, "Richard Biener" wrote: > >Now comments on the patch itself. > >+ if (code == COND_EXPR) >+ *v_reduc_type = COND_REDUCTION; > >so why not simply use COND_EXPR instead of the new v_reduc_type? v_reduc_type is also dependant on

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-14 Thread Bill Schmidt
On Mon, 2015-09-14 at 10:47 +0100, Alan Lawrence wrote: > On 11/09/15 14:19, Bill Schmidt wrote: > > > > A secondary concern for powerpc is that REDUC_MAX_EXPR produces a scalar > > that has to be broadcast back to a vector, and the best way to implement > > it for us already has the max value in

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-14 Thread Alan Lawrence
On 11/09/15 14:19, Bill Schmidt wrote: A secondary concern for powerpc is that REDUC_MAX_EXPR produces a scalar that has to be broadcast back to a vector, and the best way to implement it for us already has the max value in all positions of a vector. But that is something we should be able to

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Ramana Radhakrishnan
>>> Saying that all reductions have equivalent performance is unlikely to be >>> true for many platforms. On PowerPC, for example, a PLUS reduction has >>> very different cost from a MAX reduction. If the model isn't >>> fine-grained enough, let's please be aggressive about fixing it. I'm >>>

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Alan Hayward
Hi Bill, I’d be a bit worried about asking the backend for the cost of a COND_REDUCTION, as that will rely on the backend understanding the implementation the vectorizer is using - every time the vectorizer changed, the backends would need to be updated too. I’m hoping soon to get together a

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Ramana Radhakrishnan
On Fri, Sep 11, 2015 at 2:19 PM, Bill Schmidt wrote: > Hi Alan, > > I probably wasn't clear enough. The implementation in the vectorizer is > fine and I'm not asking that to change per target. What I'm objecting > to is the equivalence between a REDUC_MAX_EXPR and a

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Bill Schmidt
Hi Alan, I probably wasn't clear enough. The implementation in the vectorizer is fine and I'm not asking that to change per target. What I'm objecting to is the equivalence between a REDUC_MAX_EXPR and a cost associated with vec_to_scalar. This assumes that the back end will implement a

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Richard Sandiford
Ramana Radhakrishnan writes: > On Fri, Sep 11, 2015 at 2:19 PM, Bill Schmidt > wrote: >> Hi Alan, >> >> I probably wasn't clear enough. The implementation in the vectorizer is >> fine and I'm not asking that to change per target. What I'm

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Bill Schmidt
On Fri, 2015-09-11 at 15:29 +0100, Richard Sandiford wrote: > Ramana Radhakrishnan writes: > > On Fri, Sep 11, 2015 at 2:19 PM, Bill Schmidt > > wrote: > >> Hi Alan, > >> > >> I probably wasn't clear enough. The implementation in the

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Richard Sandiford
Bill Schmidt writes: > On Fri, 2015-09-11 at 15:29 +0100, Richard Sandiford wrote: >> Ramana Radhakrishnan writes: >> > On Fri, Sep 11, 2015 at 2:19 PM, Bill Schmidt >> > wrote: >> >> Hi Alan, >> >> >> >> I

Re: [PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-11 Thread Bill Schmidt
On Fri, 2015-09-11 at 16:28 +0100, Richard Sandiford wrote: > Bill Schmidt writes: > > On Fri, 2015-09-11 at 15:29 +0100, Richard Sandiford wrote: > >> Ramana Radhakrishnan writes: > >> > On Fri, Sep 11, 2015 at 2:19 PM, Bill Schmidt > >> >

[PATCH] vectorizing conditional expressions (PR tree-optimization/65947)

2015-09-10 Thread Alan Hayward
Hi, This patch (attached) adds support for vectorizing conditional expressions (PR 65947), for example: int condition_reduction (int *a, int min_v) { int last = 0; for (int i = 0; i < N; i++) if (a[i] < min_v) last = a[i]; return last; } To do this the loop is vectorised to