> +;; Zvdota dot-product instructions.  The accumulator always has 
> EMUL=1,
> +;; independently of the source LMUL.
> +
> +(define_insn "@pred_<dot_name>_vv_zvdota<mode>"
> +  [(set (match_operand:<V_QUAD_EXT_LMUL1> 0 "register_operand"             
> "=&vr")
> +     (if_then_else:<V_QUAD_EXT_LMUL1>
> +       (unspec:<VM>
> +         [(match_operand:<VM> 1 "vector_mask_operand"              "vmWc1")
> +          (match_operand 5 "vector_length_operand"                 "rvl")
> +          (match_operand 6 "const_int_operand"                     "i")
> +          (match_operand 7 "const_int_operand"                     "i")
> +          (match_operand 8 "const_int_operand"                     "i")
> +          (reg:SI VL_REGNUM)
> +          (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
> +       (unspec:<V_QUAD_EXT_LMUL1>
> +         [(match_operand:VI_QH_SCALABLE 3 "register_operand"       "vr")
> +          (match_operand:VI_QH_SCALABLE 4 "register_operand"       "vr")
> +          (match_operand:<V_QUAD_EXT_LMUL1> 2 "register_operand"   "0")]
> +         ZVQWDOT)
> +       (match_dup 2)))]
> +  "TARGET_VECTOR
> +   && ((GET_MODE_INNER (<MODE>mode) == QImode && TARGET_ZVQWDOTA8I)
> +       || (GET_MODE_INNER (<MODE>mode) == HImode && TARGET_ZVQWDOTA16I
> +        && TARGET_VECTOR_ELEN_64))"
> +  "<dot_asm>.vv\t%0,%3,%4%p1"
> +  [(set_attr "type" "vidota")
> +   (set_attr "mode" "<MODE>")
> +   (set (attr "altfmt") (symbol_ref "riscv_vector::<dot_altfmt>"))])

I'm only realizing this now but why does this look different than 
existing reductions?  Those are wrapped inside UNSPEC entirely but here 
we're using the regular scheme.  I'm not sure this is entirely correct 
here even if no pass actually uses that information yet.  Could you 
re-check?  I.e. right now we claim that a mask of the same size as the 
sources can "turn off" elements of the accumulator.

Also, we tend to keep the insn condition small and wrap the condition in 
an iterator.  I think that would also work here:

(define_mode_iterator VI_ZVQWDOTA or something

> +  /* CI selects eight accumulator elements, independently of VL and 
> the
> +     compiler accumulator type's LMUL.  Only use an exact VLEN here: a
> +     scalable target can guard larger offsets using the runtime VLEN.  */
> +  if (argno >= 3 && BITS_PER_RISCV_VECTOR.is_constant ())
> +    {
> +      machine_mode acc_mode = arg_mode (argno - 3);
> +      if (VECTOR_MODE_P (acc_mode))

Nit: I'd check acc_mode.is_constant () instead.  It shouldn't matter as 
builtins always use VLA modes (even if they are constant) but makes it 
more consistent.

-- 
Regards
 Robin

Reply via email to