tree-optimization/107435 - ICE with recurrence vectorization
authorRichard Biener <rguenther@suse.de>
Fri, 28 Oct 2022 11:50:57 +0000 (13:50 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 28 Oct 2022 13:07:02 +0000 (15:07 +0200)
This implements the missed conversion from pointer to integer.

PR tree-optimization/107435
* tree-vect-loop.cc (vectorizable_recurr): Convert initial
value to vector component type.

* gcc.dg/torture/pr107435.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr107435.c [new file with mode: 0644]
gcc/tree-vect-loop.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr107435.c b/gcc/testsuite/gcc.dg/torture/pr107435.c
new file mode 100644 (file)
index 0000000..1012896
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */
+
+struct qlist_head {
+  struct qlist_head *next;
+};
+void
+qlist_add (struct qlist_head *new, struct qlist_head *head)
+{
+  struct qlist_head *prev = head;
+  new->next = head->next;
+  prev->next = new;
+}
+struct {
+  struct qlist_head queue_link;
+} free_list, prealloc[64];
+void
+dbpf_open_cache_initialize()
+{
+  int i = 0;
+  for (; i < 64; i++)
+    qlist_add(&prealloc[i].queue_link, &free_list.queue_link);
+}
index d5c2bff..aacbb12 100644 (file)
@@ -8469,6 +8469,12 @@ vectorizable_recurr (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
   edge pe = loop_preheader_edge (LOOP_VINFO_LOOP (loop_vinfo));
   basic_block bb = gimple_bb (phi);
   tree preheader = PHI_ARG_DEF_FROM_EDGE (phi, pe);
+  if (!useless_type_conversion_p (TREE_TYPE (vectype), TREE_TYPE (preheader)))
+    {
+      gimple_seq stmts = NULL;
+      preheader = gimple_convert (&stmts, TREE_TYPE (vectype), preheader);
+      gsi_insert_seq_on_edge_immediate (pe, stmts);
+    }
   tree vec_init = build_vector_from_val (vectype, preheader);
   vec_init = vect_init_vector (loop_vinfo, stmt_info, vec_init, vectype, NULL);