https://gcc.gnu.org/g:6588bfab5c13fb4c3e47dd7e1a1aab86c9b70308

commit r16-4536-g6588bfab5c13fb4c3e47dd7e1a1aab86c9b70308
Author: Richard Biener <[email protected]>
Date:   Tue Oct 21 11:09:41 2025 +0200

    Fix partial epilog for bool vectors
    
    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.

Diff:
---
 gcc/tree-vect-loop.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 6c2420249718..455205069f60 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -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;
 }

Reply via email to