]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix partial epilog for bool vectors
authorRichard Biener <rguenther@suse.de>
Tue, 21 Oct 2025 09:09:41 +0000 (11:09 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 21 Oct 2025 11:18:11 +0000 (13:18 +0200)
When we do epilogue vectorization the partial reduction of a bool
vector via vect_create_partial_epilog ends up being done on an
integer vector but we fail to pun back to a bool vector at the end,
causing an ICE later.  I couldn't manage to create a testcase
running into the failure but a pending patch will expose this on
gcc.dg/vect/vect-switch-ifcvt-3.c

* tree-vect-loop.cc (vect_create_partial_epilog): Pun back
to the requested type if necessary.

gcc/tree-vect-loop.cc

index 6c2420249718237c4f70720b2bd03d4951bd8a5d..455205069f6034e8d0d6cb9c5dd4cd5ee15ad9b9 100644 (file)
@@ -5219,6 +5219,15 @@ vect_create_partial_epilog (tree vec_def, tree vectype, code_helper code,
 
       new_temp = gimple_build (seq, code, vectype1, dst1, dst2);
     }
+  if (!useless_type_conversion_p (vectype, TREE_TYPE (new_temp)))
+    {
+      tree dst3 = make_ssa_name (vectype);
+      gimple *epilog_stmt = gimple_build_assign (dst3, VIEW_CONVERT_EXPR,
+                                                build1 (VIEW_CONVERT_EXPR,
+                                                        vectype, new_temp));
+      gimple_seq_add_stmt_without_update (seq, epilog_stmt);
+      new_temp = dst3;
+    }
 
   return new_temp;
 }