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

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Here is the omp-simd-clone.cc code to create the mask types and arguments,
which should hopefully show up everything that needs to be matched on the
vectorizer side:
      tree base_type = simd_clone_compute_base_data_type (sc->origin, sc);
      tree mask_type;
      if (INTEGRAL_TYPE_P (base_type) || POINTER_TYPE_P (base_type))
        veclen = sc->vecsize_int;
      else
        veclen = sc->vecsize_float;
      if (known_eq (veclen, 0U))
        veclen = sc->simdlen;
      else
        veclen = exact_div (veclen,
                            GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type)));
      if (multiple_p (veclen, sc->simdlen))
        veclen = sc->simdlen;
      if (sc->mask_mode != VOIDmode)
        mask_type
          = lang_hooks.types.type_for_mode (sc->mask_mode, 1);
      else if (POINTER_TYPE_P (base_type))
        mask_type = build_vector_type (pointer_sized_int_node, veclen);
      else
        mask_type = build_vector_type (base_type, veclen);

      k = vector_unroll_factor (sc->simdlen, veclen);

      /* We have previously allocated one extra entry for the mask.  Use
         it and fill it.  */
      sc->nargs++;
      if (sc->mask_mode != VOIDmode)
        base_type = boolean_type_node;
      if (node->definition)
        {
          sc->args[i].orig_arg
            = build_decl (UNKNOWN_LOCATION, PARM_DECL, NULL, base_type);
          if (sc->mask_mode == VOIDmode)
            sc->args[i].simd_array
              = create_tmp_simd_array ("mask", base_type, sc->simdlen);
          else if (k > 1)
            sc->args[i].simd_array
              = create_tmp_simd_array ("mask", mask_type, k);
          else
            sc->args[i].simd_array = NULL_TREE;
        }
      sc->args[i].orig_type = base_type;
      sc->args[i].arg_type = SIMD_CLONE_ARG_TYPE_MASK;
      sc->args[i].vector_type = mask_type;

The target hook can set sc->mask_mode to non-VOIDmode for the x86 ZMM like
cases, i.e. scalar bitmask argument (or scalar bitmasks),
VOIDmode for a normal vector of the characteristic data type.  The first line
computes the characteristic data type.
Then veclen is either sc->simdlen, or sc->simdlen is some integral multiple of
veclen, k is what will be ncopies on the vectorizer side.
The vector_type then is some scalar or vector type handling veclen masks and
there will be k arguments of this kind in the end,
but just one SIMD_CLONE_ARG_TYPE_MASK covering them all.

Reply via email to