From: Richard Biener Date: Tue, 1 Apr 2025 12:13:03 +0000 (+0200) Subject: tree-optimization/119534 - reject bogus emulated vectorized gather X-Git-Tag: basepoints/gcc-16~424 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0cc14c62ad7403afcab3c2e38851d3ab179352f;p=thirdparty%2Fgcc.git tree-optimization/119534 - reject bogus emulated vectorized gather The following makes sure to reject the attempts to emulate a vector gather when the discovered index vector type is a vector mask. PR tree-optimization/119534 * tree-vect-stmts.cc (get_load_store_type): Reject VECTOR_BOOLEAN_TYPE_P offset vector type for emulated gathers. * gcc.dg/vect/pr119534.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/vect/pr119534.c b/gcc/testsuite/gcc.dg/vect/pr119534.c new file mode 100644 index 00000000000..0b4130b7cfa --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr119534.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx512bw" { target { x86_64-*-* i?86-*-* } } } */ + +void f(int w, int *out, double *d) +{ + for (int j = 0; j < w; j++) + { + const int i = (j >= w / 2); + out[j] += d[i]; + } +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 813b2b77951..8bd5ea96667 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -2522,6 +2522,7 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, { if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant () || !TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype).is_constant () + || VECTOR_BOOLEAN_TYPE_P (gs_info->offset_vectype) || !constant_multiple_p (TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype), TYPE_VECTOR_SUBPARTS (vectype)))