Forgot to CC maintainer.
On 15/11/2019 18:03, Joel wrote:
> Hi all,
>
> Just looking for some feedback on the approach.
>
> Currently the loop vectorizer can't vectorize the following typical
> loop for getting max value and index from an array:
>
> void test_vec(int *data, int n) {
> int best_i, best = 0;
>
> for (int i = 0; i < n; i++) {
> if (data[i] > best) {
> best = data[i];
> best_i = i;
> }
> }
>
> data[best_i] = data[0];
> data[0] = best;
> }
>
> This patch adds some support for this pattern.
>
> This patch addresses Bug 88259.
>
> Regression testing is still in progress,
> This patch does not work correctly with vect-epilogues-nomask, and the
> reason for that is still being investigated.
>
> gcc/ChangeLog:
>
>
> 2019-11-15 Joel Hutton <joel.hut...@arm.com>
> Tamar Christina <tamar.christ...@arm.com>
>
> PR tree-optimization/88259
> * tree-vect-loop.c (vect_reassociating_reduction_simple_p): New
> function.
> (vect_recog_minmax_index_pattern): New function.
> (vect_is_simple_reduction): Add check for minmax pattern.
> (vect_model_reduction_cost): Add case for minmax pattern.
> (vect_create_epilog_for_reduction): Add fixup for minmax epilog.
> * tree-vectorizer.h (enum vect_reduction_type): Add
> INDEX_MINMAX_REDUCTION reduction type.