https://gcc.gnu.org/g:0091900417570a0d70c9d382ec4491dbe12fb01f
commit r17-5672-g0091900417570a0d70c9d382ec4491dbe12fb01f Author: Richard Biener <[email protected]> Date: Wed Oct 28 15:11:48 2026 +0100 tree-optimization/128189 - ICE with OMP SIMD vectorization of uniform arg When we cannot compute a vector type for an uniform arg of a SIMD function we'll ICE, latest when assigning the vector type to the SLP node if it is invariant. Give up for such uniform args. If passing the scalar argument would be OK we should refrain from tracking it in a SLP node (or generally enhance that to handle "scalar lanes"). PR tree-optimization/128189 * tree-vect-stmts.cc (vectorizable_simd_clone_call): When the vector type of an argument cannot be computed, fail. * gcc.dg/vect/vect-simd-pr128189.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/vect-simd-pr128189.c | 15 +++++++++++++++ gcc/tree-vect-stmts.cc | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-pr128189.c b/gcc/testsuite/gcc.dg/vect/vect-simd-pr128189.c new file mode 100644 index 000000000000..472e1db13557 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-pr128189.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#pragma omp declare simd uniform(x) simdlen(4) notinbranch +extern void f(_Complex double x); + +void g(int *restrict d, _Complex double x, int n) +{ +#pragma omp simd + for (int i = 0; i < n; i++) + { + f(x); + d[i] = 1; + } +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 0a884d491e33..b33d3f6b7826 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -4176,9 +4176,21 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info, gcc_assert (cost_vec || thisarginfo.vectype != NULL_TREE); if (cost_vec) - thisarginfo.vectype = get_vectype_for_scalar_type (vinfo, - TREE_TYPE (op), - slp_node); + { + thisarginfo.vectype = get_vectype_for_scalar_type (vinfo, + TREE_TYPE (op), + slp_node); + /* ??? While for example uniform arguments might not need + a vector type we are not set up to handle this case + right now. */ + if (!thisarginfo.vectype) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "no vector type for argument.\n"); + return false; + } + } } else gcc_assert (thisarginfo.vectype != NULL_TREE);
