On 12/18/2017 02:50 PM, Jakub Jelinek wrote:
> Hi!
>
> When backporting the wrong-code bugfix parts of PR80631 to 7.3, I've noticed
> that we perform the optimization to use the induc_val only when reduc_fn is
> IFN_REDUC_{MAX,MIN}. That is true e.g. for AVX2, but not plain SSE2, so if
> we have a loop like:
> void foo (int *v)
> {
> int found_index = -17;
> for (int k = 0; k < 64; k++)
> if (v[k] == 77)
> found_index = k;
> return found_index;
> }
> we start with { -17, -17, -17... } only for avx* and can optimize away
> the scalar if (reduc_result == -17 ? -17 : reduc_result, but for sse*
> we start instead with { -1, -1, -1... } and can't optimize
> if (reduc_result == -1 ? -17 : reduc_result.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2017-12-18 Jakub Jelinek <ja...@redhat.com>
>
> PR tree-optimization/80631
> * tree-vect-loop.c (vect_create_epilog_for_reduction): Compare
> induc_code against MAX_EXPR or MIN_EXPR instead of reduc_fn against
> IFN_REDUC_MAX or IFN_REDUC_MIN.
OK.
jeff