https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122762

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |122736

--- Comment #20 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #19)
> (In reply to Richard Biener from comment #18)
> > so here we have a simdclone with 'unsigned int' vector_type for its
> > SIMD_CLONE_ARG_TYPE_MASK.  That's unexpected.
> 
> That is a normal expected case, that just means that the mask argument is
> passed
> as bits inside of unsigned int (ncopies unsigned int arguments in
> particular, each one
> holding simdlen / ncopies bits).  See the above omp-simd-clone.cc code which
> sets it up that way.

Hmm.  OK.

So then I suppose the confusion is with what data vector type to associate the
SIMD_CLONE_ARG_TYPE_MASK argument.  As it seems that vector_type is not
useable as-is, at least for AVX512, we need some vector type to record/query
the loop mask for.  On the use side we fail to AND the loop mask with any
.COND_CALL (...), that's wrong-code, but for a regular call masked loop we do

          tree masktype = bestn->simdclone->args[mask_i].vector_type;
          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++)
            {
              if (loop_vinfo && LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
                {
                  vec_loop_masks *loop_masks = &LOOP_VINFO_MASKS (loop_vinfo);
                  mask = vect_get_loop_mask (loop_vinfo, gsi, loop_masks,
                                             ncopies, masktype, j);

for an integer masktype this call will ICE.  Originally on the mask
recording side we used 'vectype', so possibly that would be correct here,
too.  This is possibly the base_type in the simdclone code you quote.

Unfortunately this doesn't allow me to revert r16-5374-g5c2fdfc24e343c
without re-introducing PR122736.  *sigh*

But it would fix the gcc.dg/vect/vect-simd-clone-20.c ICE.

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 748b3bcb0ab..627d940c023 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -4885,7 +4885,7 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
                {
                  vec_loop_masks *loop_masks = &LOOP_VINFO_MASKS (loop_vinfo);
                  mask = vect_get_loop_mask (loop_vinfo, gsi, loop_masks,
-                                            ncopies, masktype, j);
+                                            ncopies, vectype, j);
                }
              else
                mask = vect_build_all_ones_mask (vinfo, stmt_info, masktype);


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122736
[Bug 122736] loop masking with SIMD clones ICEs in vect_verify_full_masking

Reply via email to