https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128189
Bug ID: 128189
Summary: vect: ICE in vectorizable_simd_clone_call for uniform
_Complex double argument of omp declare simd function
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: dohanam2 at illinois dot edu
Target Milestone: ---
The vectorizer crashes with a segmentation fault in
`vectorizable_simd_clone_call` when an `omp simd` loop calls a `declare simd`
function whose only argument is a `uniform` `_Complex double`.
```c
#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; }
}
```
```
cc1 -quiet -O2 -fopenmp-simd input.c -o /dev/null
```
```
during GIMPLE pass: vect
input.c: In function 'g':
input.c:3:6: internal compiler error: Segmentation fault
0x151c6eb tree_check(tree_node const*, char const*, int, char const*,
tree_code)
../../gcc/tree.h:4124
0x151c6eb TYPE_VECTOR_SUBPARTS(tree_node const*)
../../gcc/tree.h:4459
0x151c6eb vect_get_num_vectors(poly_int<1u, unsigned long>, tree_node*)
../../gcc/tree-vectorizer.h:2354
0x151c6eb vectorizable_simd_clone_call
../../gcc/tree-vect-stmts.cc:4418
0x15394ca vect_analyze_stmt(vec_info*, _slp_tree*, _slp_instance*,
vec<stmt_info_for_cost, va_heap, vl_ptr>*)
../../gcc/tree-vect-stmts.cc:13168
```
The loop is valid OpenMP and the call should be vectorized with the clone or
left scalar, not crash the compiler. The same function with `int x` or `double
x` instead compiles fine.
It reproduces at 3c80dc4603e1ece9ff75b801e75943d8c9a19b05. The build with
checking enabled crashes in `tree_check` (shown above); the release build also
fails with `internal compiler error: Segmentation fault` during the vect pass,
in `TYPE_VECTOR_SUBPARTS`.
Looks like `vectype = SLP_TREE_VECTYPE (slp_node)` in
`vectorizable_simd_clone_call` is NULL here (there is no vector type for
`_Complex double`), and `vect_get_num_vectors (vf * group_size, vectype)` at
tree-vect-stmts.cc:4418 is called without checking it.
Found with an LLM-based testing tool; I used Claude to reduce it and look for
the cause.