https://gcc.gnu.org/g:c2cc06fdce766d93e45d79ba871b12158c7691d0
commit r17-3035-gc2cc06fdce766d93e45d79ba871b12158c7691d0 Author: Richard Biener <[email protected]> Date: Wed Aug 5 09:37:53 2026 +0200 Fix latent issue in call vectorization When the first argument of a call happens to be a SLP permute node vect_is_simple_use will assign error_mark_node to the scalar op (because there's no representative). This causes subsequent argument processing to ICE because rhs_type ends up as error_mark_node as well. Fix this by getting the scalar argument type from the representative call stmt instead (the scalar 'op' result of vect_is_simple_use is legacy). The testcase runs into this with the SLP subgraph merging patch, reduced from SPEC CPU 2017. * tree-vect-stmts.cc (vectorizable_call): Get scalar argument type from the representative call stmt. * gcc.dg/vect/bb-slp-78.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/bb-slp-78.c | 19 +++++++++++++++++++ gcc/tree-vect-stmts.cc | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-78.c b/gcc/testsuite/gcc.dg/vect/bb-slp-78.c new file mode 100644 index 000000000000..6ca04d87e774 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-78.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=x86-64-v2" { target { x86_64-*-* i?86-*-* } } } */ + +typedef struct { + float xmin, xmax; + float ymin, ymax; +} rctf; +short U_0; +int node_find_indicated_socket_in_out; +void BLI_rctf_isect_pt(rctf *); +void node_find_indicated_socket(float cursor[]) +{ + rctf rect; + rect.xmin = rect.ymin = cursor[1] - 4; + rect.xmax = rect.ymax = cursor[1] + 0; + if (node_find_indicated_socket_in_out) + rect.xmax += rect.xmin -= U_0; + BLI_rctf_isect_pt(&rect); +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 419b49596664..518ce00d585a 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -3410,7 +3410,6 @@ vectorizable_call (vec_info *vinfo, gcall *stmt; tree vec_dest; tree scalar_dest; - tree op; tree vec_oprnd0 = NULL_TREE; tree vectype_out, vectype_in; poly_uint64 nunits_in; @@ -3502,7 +3501,7 @@ vectorizable_call (vec_info *vinfo, } if (!vect_is_simple_use (vinfo, slp_node, - i, &op, &slp_op[i], &dt[i], &vectypes[i])) + i, &slp_op[i], &dt[i], &vectypes[i])) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -3511,6 +3510,7 @@ vectorizable_call (vec_info *vinfo, } /* We can only handle calls with arguments of the same type. */ + tree op = gimple_call_arg (stmt, i); if (rhs_type && !types_compatible_p (rhs_type, TREE_TYPE (op))) {
