When boolean vectors do not use vector integer modes we are not
set up to produce the partial epilog in a correctly typed way,
so avoid this situation. For the integer mode case we are able
to pun things correctly, so keep that working.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/122885
* tree-vect-loop.cc (vect_find_reusable_accumulator): Reject
mask vectors which do not use integer vector modes.
(vect_create_partial_epilog): Assert the same.
* gcc.dg/torture/pr122873.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr122873.c | 13 +++++++++++++
gcc/tree-vect-loop.cc | 9 +++++++++
2 files changed, 22 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr122873.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr122873.c
b/gcc/testsuite/gcc.dg/torture/pr122873.c
new file mode 100644
index 00000000000..1eadceedcd8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr122873.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=armv9-a -msve-vector-bits=128" { target {
aarch64-*-* } } } */
+/* { dg-additional-options "-mavx512bw -mavx512vl --param
vect-partial-vector-usage=1" { target { avx512bw && avx512vl } } } */
+
+char *b;
+bool c(int l)
+{
+ bool d = true;
+ for (int a = 0; a < l; a++)
+ if (b[a])
+ d = false;
+ return d;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index fe78107fe04..ab6c0f08470 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -5026,6 +5026,12 @@ vect_find_reusable_accumulator (loop_vec_info loop_vinfo,
if (VECT_REDUC_INFO_TYPE (reduc_info) != TREE_CODE_REDUCTION)
return false;
+ /* We are not set up to handle vector bools when they are not mapped
+ to vector integer data types. */
+ if (VECTOR_BOOLEAN_TYPE_P (vectype)
+ && GET_MODE_CLASS (TYPE_MODE (vectype)) != MODE_VECTOR_INT)
+ return false;
+
unsigned int num_phis = VECT_REDUC_INFO_INITIAL_VALUES (reduc_info).length
();
auto_vec<tree, 16> main_loop_results (num_phis);
auto_vec<tree, 16> initial_values (num_phis);
@@ -5126,6 +5132,9 @@ static tree
vect_create_partial_epilog (tree vec_def, tree vectype, code_helper code,
gimple_seq *seq)
{
+ gcc_assert (!VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (vec_def))
+ || (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (vec_def)))
+ == MODE_VECTOR_INT));
unsigned nunits = TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec_def)).to_constant ();
unsigned nunits1 = TYPE_VECTOR_SUBPARTS (vectype).to_constant ();
tree stype = TREE_TYPE (vectype);
--
2.51.0