Hi! As discussed in the PR, the reduction code isn't able to cope with type promotions/demotions in the reduction computation, so if we recognize an over-widening pattern that has vect_reduction_def type, we most likely make it non-vectorizable.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for turnk? 2021-02-02 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/98848 * tree-vect-patterns.c (vect_recog_over_widening_pattern): Punt if STMT_VINFO_DEF_TYPE (last_stmt_info) is vect_reduction_def. * gcc.dg/vect/pr98848.c: New test. * gcc.dg/vect/pr92205.c: Remove xfail. --- gcc/tree-vect-patterns.c.jj 2021-01-04 10:25:38.650235896 +0100 +++ gcc/tree-vect-patterns.c 2021-02-01 11:04:48.136814236 +0100 @@ -1579,6 +1579,10 @@ vect_recog_over_widening_pattern (vec_in tree type = TREE_TYPE (lhs); tree_code code = gimple_assign_rhs_code (last_stmt); + /* Punt for reductions where we don't handle the type conversions. */ + if (STMT_VINFO_DEF_TYPE (last_stmt_info) == vect_reduction_def) + return NULL; + /* Keep the first operand of a COND_EXPR as-is: only the other two operands are interesting. */ unsigned int first_op = (code == COND_EXPR ? 2 : 1); --- gcc/testsuite/gcc.dg/vect/pr98848.c.jj 2021-02-01 11:15:11.965633750 +0100 +++ gcc/testsuite/gcc.dg/vect/pr98848.c 2021-02-01 11:15:07.348686891 +0100 @@ -0,0 +1,18 @@ +/* PR tree-optimization/98848 */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +short a[9000]; + +int +foo (void) +{ + int b = a[0]; + int i; + for (i = 1; i < 9000; i ++) + if (a[i] < b) + b = a[i]; + return b; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { xfail { vect_no_int_add || vect_no_int_min_max } } } } */ --- gcc/testsuite/gcc.dg/vect/pr92205.c.jj 2020-01-12 11:54:37.645394821 +0100 +++ gcc/testsuite/gcc.dg/vect/pr92205.c 2021-02-02 09:59:40.998104863 +0100 @@ -10,4 +10,4 @@ int b(int n, unsigned char *a) return d; } -/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_unpack && { ! vect_no_bitwise } } } } } */ Jakub