https://gcc.gnu.org/g:4f4478f0f31263997bfdc4159f90e58dd79b38f9

commit r15-1990-g4f4478f0f31263997bfdc4159f90e58dd79b38f9
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Jul 11 10:18:55 2024 +0200

    tree-optimization/115867 - ICE with simdcall vectorization in masked loop
    
    When only a loop mask is to be supplied for the inbranch arg to a
    simd function we fail to handle integer mode masks correctly.  We
    need to guess the number of elements represented by it.  This assumes
    that excess arguments are all for masks, I wasn't able to create
    a simdclone with more than one integer mode mask argument.
    
    The gcc.dg/vect/vect-simd-clone-20.c exercises this with -mavx512vl
    
            PR tree-optimization/115867
            * tree-vect-stmts.cc (vectorizable_simd_clone_call): Properly
            guess the number of mask elements for integer mode masks.

Diff:
---
 gcc/tree-vect-stmts.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index fdcda0d2abae..2e4d500d1f26 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -4748,7 +4748,12 @@ vectorizable_simd_clone_call (vec_info *vinfo, 
stmt_vec_info stmt_info,
                      SIMD_CLONE_ARG_TYPE_MASK);
 
          tree masktype = bestn->simdclone->args[mask_i].vector_type;
-         callee_nelements = TYPE_VECTOR_SUBPARTS (masktype);
+         if (SCALAR_INT_MODE_P (bestn->simdclone->mask_mode))
+           /* Guess the number of lanes represented by masktype.  */
+           callee_nelements = exact_div (bestn->simdclone->simdlen,
+                                         bestn->simdclone->nargs - nargs);
+         else
+           callee_nelements = TYPE_VECTOR_SUBPARTS (masktype);
          o = vector_unroll_factor (nunits, callee_nelements);
          for (m = j * o; m < (j + 1) * o; m++)
            {

Reply via email to