https://gcc.gnu.org/g:4bf7a4de5037671d7021c4b1d60dcd47fa5760e6
commit r17-5967-g4bf7a4de5037671d7021c4b1d60dcd47fa5760e6 Author: Richard Biener <[email protected]> Date: Wed Oct 28 14:16:12 2026 +0100 tree-optimization/128188 - hang with OMP simd vectorization The following makes sure that vect_simd_lane_linear does not loop indefinitely. PR tree-optimization/128188 * tree-vect-stmts.cc (vect_simd_lane_linear): Return when the definition v is not handled, avoiding an endless loop. * gcc.dg/vect/vect-simd-pr128188.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/vect-simd-pr128188.c | 17 +++++++++++++++++ gcc/tree-vect-stmts.cc | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-pr128188.c b/gcc/testsuite/gcc.dg/vect/vect-simd-pr128188.c new file mode 100644 index 000000000000..b16261efe6f5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-pr128188.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fopenmp-simd -fno-tree-loop-im -fno-tree-pre" } */ + +#pragma omp declare simd linear(p:1) notinbranch +extern int update(int *p, int x); + +void f(int *restrict d, const int *restrict a, int n, int m) +{ +#pragma omp simd + for (int i = 0; i < n; i++) + { + int t = a[i]; +#pragma omp simd + for (int j = 0; j < m; j++) + d[i*m+j] = update(&t, a[j]); + } +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 6285f8581ad7..f08152009e2a 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -4051,8 +4051,8 @@ vect_simd_lane_linear (tree op, class loop *loop, arginfo->linear_step = linear_step; arginfo->op = base; arginfo->simd_lane_linear = true; - return; } + return; } }
