[PATCH] Fix latent issue in call vectorization
Richard Biener <[email protected]> Thu, 6 Aug 2026 15:43:06 +0200 (CEST)
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
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.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
* tree-vect-stmts.cc (vectorizable_call): Get scalar argument
type from the representative call stmt.
* gcc.dg/vect/bb-slp-78.c: New testcase.
---
gcc/testsuite/gcc.dg/vect/bb-slp-78.c | 19 +++++++++++++++++++
gcc/tree-vect-stmts.cc | 4 ++--
2 files changed, 21 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-78.c
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 00000000000..6ca04d87e77
--- /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 57026ba8b0f..7ecbc8fb391 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -3412,7 +3412,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;
@@ -3504,7 +3503,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,
@@ -3513,6 +3512,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)))
{
--
2.51.0