When the SIMD clone mask argument has a vector type with BLKmode we
ICE when attempting to build the respective mask type. Use
truth_type_for for !VECTOR_BOOLEAN_TYPE_P which handles that case
just fine and as we are going to create a all-one constant mask is not
an issue if that were to have BLKmode as well. For the
VECTOR_BOOLEAN_TYPE_P case only re-construct mask types with
a vector mode which matches the aarch64 case we do this dance for.
I've also filled a hole of mask-mode verification for inbranch
clone use for a not-inbranch use.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/128225
* tree-vect-stmts.cc (vectorizable_simd_clone_call): Only
use build_truth_vector_type_for_mode for vector mode
vector boolean types.
Check mask_mode of the simdclone is a supported one even
if the inbranch clone is going to be used for a not-inbranch use.
* gcc.dg/vect/vect-simd-clone-pr128225.c: New testcase.
---
.../gcc.dg/vect/vect-simd-clone-pr128225.c | 14 ++++++++++
gcc/tree-vect-stmts.cc | 26 ++++++++++++-------
2 files changed, 31 insertions(+), 9 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-simd-clone-pr128225.c
diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-pr128225.c
b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-pr128225.c
new file mode 100644
index 00000000000..b7a383ffc12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-pr128225.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_simd_clones } */
+/* { dg-additional-options "-fopenmp-simd" } */
+/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */
+
+#pragma omp declare simd simdlen(2) inbranch
+extern float clone(double) __attribute__((const));
+
+void use(float *restrict d, const double *restrict a, int n)
+{
+#pragma omp simd
+ for (int i = 0; i < n; i++)
+ d[i] = clone(a[i]);
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 2162ccbbc8f..3abba22a19e 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -4406,6 +4406,9 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
{
gcc_assert (n->simdclone->args[n->simdclone->nargs - 1].arg_type ==
SIMD_CLONE_ARG_TYPE_MASK);
+ if (!SCALAR_INT_MODE_P (n->simdclone->mask_mode)
+ && n->simdclone->mask_mode != VOIDmode)
+ continue;
/* Penalize using a masked SIMD clone in a non-masked loop, that is
not in a branch, as we'd have to construct an all-true mask. */
this_badness += 64;
@@ -4517,15 +4520,20 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
else
{
masktype = bestn_inbranch->simdclone->args[i].vector_type;
- /* The aarch64 port will add custom attributes to types
- for SVE simdclones which make the types different. We
- should use canonincal types for masks within the
- vectorizer, hence we construct the related vectype
- here. */
- masktype
- = build_truth_vector_type_for_mode
- (TYPE_VECTOR_SUBPARTS (masktype),
- TYPE_MODE (masktype));
+ if (VECTOR_BOOLEAN_TYPE_P (masktype))
+ {
+ if (VECTOR_MODE_P (TYPE_MODE (masktype)))
+ /* The aarch64 port will add custom attributes to
+ types for SVE simdclones which make the types
+ different. We should use canonincal types for
+ masks within the vectorizer, hence we
+ re-construct the vectype from its mode. */
+ masktype = build_truth_vector_type_for_mode
+ (TYPE_VECTOR_SUBPARTS (masktype),
+ TYPE_MODE (masktype));
+ }
+ else
+ masktype = truth_type_for (masktype);
callee_nelements = TYPE_VECTOR_SUBPARTS (masktype);
}
if (!masktype)
base-commit: fba8ef7b727a9d3769accf7eb226af4577b738cb
--
2.51.0