diff --git a/gcc/testsuite/gcc.dg/vect/pr114108.c b/gcc/testsuite/gcc.dg/vect/pr114108.c new file mode 100644 index 0000000000000000000000000000000000000000..b3075d41398edf2a01b4094bdb70a10b8d39b298 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr114108.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +#include "tree-vect.h" + +typedef signed char schar; + +__attribute__((noipa, noinline, optimize("O3"))) +void foo(const schar *a, const schar *b, schar *c, int n) +{ + for (int i = 0; i < n; i++) + { + unsigned u = __builtin_abs (a[i] - b[i]); + c[i] = u <= 7U ? u : 7U; + } +} + + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump "vect_recog_abd_pattern: detected" "vect" { target aarch64*-*-* } } } */ diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index d562f57920f66fb31193cbb559e961cab93baf7f..4f491c6b8336f8710c3519dec1fa7e0f49387d2b 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -1576,9 +1576,8 @@ vect_recog_abd_pattern (vec_info *vinfo, && !TYPE_UNSIGNED (abd_out_type)) { tree unsign = unsigned_type_for (abd_out_type); - tree unsign_vectype = get_vectype_for_scalar_type (vinfo, unsign); - stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt, - unsign_vectype); + stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt, vectype_out); + vectype_out = get_vectype_for_scalar_type (vinfo, unsign); } return vect_convert_output (vinfo, stmt_vinfo, out_type, stmt, vectype_out);