+ tree_code m_code;
+
+ /* Used to redirect the low forms to the high forms. */
+ high_form m_high;
+
+ /* The first multiplicand is operand 0 for VMULL and 1 otherwise. */
+ int first_mult_arg () const { return m_code != ERROR_MARK; }
+
+ /* Return the VECTOR_CST corresponding to VAL if it is one or if it is an
+ SSA_NAME which defines one. */
+ tree vector_constant_value (tree val) const
+ {
+ if (TREE_CODE (val) == SSA_NAME)
+ {
+ gimple *def = SSA_NAME_DEF_STMT (val);
+ if (gimple_assign_single_p (def))
+ val = gimple_assign_rhs1 (def);
+ }
+
+ return TREE_CODE (val) == VECTOR_CST ? val : NULL_TREE;
+ }
+
+ /* Return true if VAL can be profitably passed to the high form. */
+ bool widenable_for_high_form_p (tree val) const
+ {
+ return aarch64_v128_highpart_src_reg (val) != NULL_TREE
+ || vector_constant_value (val) != NULL_TREE
+ || ssa_uniform_vector_p (val) != NULL_TREE;
+ }
+
+ /* Build and return the 128-bit vector that the high form should be given in
+ place of VAL when widenable_for_high_form_p holds true. */
+ tree build_high_form_operand (gimple_folder &f, tree val) const
+ {
+ tree narrow_type = TREE_TYPE (val);
+ gcc_assert (known_eq (GET_MODE_BITSIZE (TYPE_MODE (narrow_type)), 64));
+ tree wide_type = build_vector_type (TREE_TYPE (narrow_type),
+ TYPE_VECTOR_SUBPARTS (narrow_type) * 2);
+
+ /* BIT_FIELD_REF of upper half. Handle vreinterprets by view-converting to
+ the actual type we want. */
+ if (tree obj = aarch64_v128_highpart_src_reg (val))
+ return types_compatible_p (TREE_TYPE (obj), wide_type)
+ ? obj
+ : f.force_val (build1 (VIEW_CONVERT_EXPR, wide_type, obj));
+
+ /* Constant. */
+ if (tree cst = vector_constant_value (val))
+ return aarch64_build_vector_cst (cst, wide_type);
+
+ /* Splat. */
+ if (tree elt = ssa_uniform_vector_p (val))
+ return f.force_val (build_vec_dup (wide_type, elt));
+
+ gcc_unreachable ();
+ }
+
+ /* Redirect the call in F to its high form if possible, otherwise return
+ NULL. */
+ gimple *redirect_to_high_form (gimple_folder &f, unsigned int first,
+ const high_form &high) const
+ {
+ if (!high.name)
+ return NULL;
+
+ tree orig1 = gimple_call_arg (f.call, first);
+ tree orig2 = gimple_call_arg (f.call, first + 1);
+
+ if (!widenable_for_high_form_p (orig1) || !widenable_for_high_form_p
(orig2)
+ || (!aarch64_v128_highpart_src_reg (orig1)
+ && !aarch64_v128_highpart_src_reg (orig2)))
+ return NULL;
+
+ function_instance instance (high.name, *high.base, *high.shape,
+ f.mode_suffix_id, f.type_suffix_ids, GROUP_none,
+ PRED_none, FPM_unused);
+ gcall *call = f.redirect_call (instance);
+ if (!call)
+ return NULL;
+
+ gimple_call_set_arg (call, first, build_high_form_operand (f, orig1));
+ gimple_call_set_arg (call, first + 1, build_high_form_operand (f, orig2));
+ return call;
+ }
+
+public:
+ constexpr gimple_widen_mult (tree_code code = ERROR_MARK,
+ high_form high = {})
+ : m_code (code), m_high (high) {}
+
+ gimple *fold (gimple_folder &f) const override
+ {
+ /* Folding is deferred until the function is in SSA form as
+ SSA_NAME_DEF_STMT is not able to look through user-defined constant
decls
+ until then. */
+ if ((cfun->curr_properties & PROP_ssa) == 0)
+ return nullptr;
+
+ int first = first_mult_arg ();
+
+ /* First try to optimize to the high form if both operands are extracts of
+ upper halves of vectors. */
+ if (gimple *high_call = redirect_to_high_form (f, first, m_high))
+ return high_call;
+
+ /* Folding is not profitable if only one operand is widenable or if the
+ resulting element size is >= 64 bits (which leads to scalarization).
Punt
+ on those cases. */
+ if (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (f.lhs))) >= 64
+ || widenable_for_high_form_p (gimple_call_arg (f.call, first))
+ || widenable_for_high_form_p (gimple_call_arg (f.call, first + 1)))
+ return NULL;
+
+ /* Otherwise translate to GIMPLE as `(WIDE_TYPE) A * (WIDE_TYPE) B`. */
+ tree wide_type = TREE_TYPE (f.lhs);
+ tree a = gimple_call_arg (f.call, first);
+ tree b = gimple_call_arg (f.call, first + 1);
+ gcc_assert (TYPE_PRECISION (TREE_TYPE (wide_type))
+ == TYPE_PRECISION (TREE_TYPE (TREE_TYPE (a))) * 2);
+ if (high_p)
+ {
+ tree half_type = build_vector_type (TREE_TYPE (TREE_TYPE (a)),
+ TYPE_VECTOR_SUBPARTS (wide_type));
+ a = f.force_val (build_vec_extract_half (half_type, a, true));
+ b = f.force_val (build_vec_extract_half (half_type, b, true));
+ }
+ a = f.force_val (fold_build1 (CONVERT_EXPR, wide_type, a));
+ b = f.force_val (fold_build1 (CONVERT_EXPR, wide_type, b));
+ tree product = fold_build2 (MULT_EXPR, wide_type, a, b);
+
+ /* Non-accumulating intrinsic. */
+ if (m_code == ERROR_MARK)
+ return gimple_build_assign (f.lhs, product);
+
+ /* Accumulating intrinsic. */
+ tree accumulator = gimple_call_arg (f.call, 0);
+ product = f.force_val (product);
+
+ /* Accumulate in an unsigned mode to match wrapping semantics. */
+ tree uwide_type = wide_type;
+ if (!TYPE_UNSIGNED (TREE_TYPE (wide_type)))
+ {
+ uwide_type = unsigned_type_for (wide_type);
+ accumulator = f.force_val (build_cast (uwide_type, accumulator));
+ product = f.force_val (build_cast (uwide_type, product));
+ }
+
+ return gimple_build_assign (
+ f.lhs,
+ build_cast (wide_type, f.force_val (fold_build2 (m_code, uwide_type,
+ accumulator, product))));
+ }
+
+ rtx expand (function_expander &e) const override
+ {
+ auto mode = GET_MODE (e.args[first_mult_arg ()]);
+ auto ext = e.type_suffix (0).unsigned_p ? ZERO_EXTEND : SIGN_EXTEND;
+
+ insn_code icode;
+ switch (m_code)
+ {
+ case ERROR_MARK:
+ icode = high_p
+ ? e.direct_optab_handler_for_sign (vec_widen_smult_hi_optab,
+ vec_widen_umult_hi_optab,
+ 0, mode)
+ : code_for_aarch64_intrinsic_vec_mult_lo (ext, mode);
+ break;
+ case PLUS_EXPR:
+ icode = high_p ? code_for_aarch64_mlal_hi (ext, mode)
+ : code_for_aarch64_mlal (ext, mode);
+ break;
+ case MINUS_EXPR:
+ icode = high_p ? code_for_aarch64_mlsl_hi (ext, mode)
+ : code_for_aarch64_mlsl (ext, mode);
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ return e.use_exact_insn (icode);
+ }
+};
+
// Reinterpret
NEON_FUNCTION (vreinterpret, vreinterpretq, gimple_reinterpret,)
@@ -815,6 +1023,20 @@ NEON_FUNCTION (vrndn, vrndnq, vrndns, gimple_ifn,
(IFN_ROUNDEVEN))
NEON_FUNCTION (vrndp, vrndpq, gimple_ifn, (IFN_CEIL))
NEON_FUNCTION (vrndx, vrndxq, gimple_ifn, (IFN_RINT))
+// Widening multiply and multiply-accumulate
+NEON_FUNCTION (vmull, gimple_widen_mult<false>,
+ (ERROR_MARK, { "vmull_high", &functions::vmull_high,
+ &shapes::vmull_high_bhs_integer_shape }))
+NEON_FUNCTION (vmull_high, gimple_widen_mult<true>,)
+NEON_FUNCTION (vmlal, gimple_widen_mult<false>,
+ (PLUS_EXPR, { "vmlal_high", &functions::vmlal_high,
+ &shapes::vmlal_high_bhs_integer_shape }))
+NEON_FUNCTION (vmlal_high, gimple_widen_mult<true>, (PLUS_EXPR))
+NEON_FUNCTION (vmlsl, gimple_widen_mult<false>,
+ (MINUS_EXPR, { "vmlsl_high", &functions::vmlsl_high,
+ &shapes::vmlsl_high_bhs_integer_shape }))
+NEON_FUNCTION (vmlsl_high, gimple_widen_mult<true>, (MINUS_EXPR))
+
// Bitwise operations
NEON_FUNCTION (vand, vandq, gimple_expr, (BIT_AND_EXPR))
NEON_FUNCTION (vbic, vbicq, gimple_not_rhs, (BIT_AND_EXPR))
diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.def
b/gcc/config/aarch64/aarch64-neon-builtins-base.def
index df33c37c34fc..c2b2e5d9033c 100644
--- a/gcc/config/aarch64/aarch64-neon-builtins-base.def
+++ b/gcc/config/aarch64/aarch64-neon-builtins-base.def
@@ -191,6 +191,16 @@ DEF_NEON_FUNCTION (vrndx, h_float, ("D0,D0"))
DEF_NEON_FUNCTION (vrndxq, h_float, ("Q0,Q0"))
#undef REQUIRED_EXTENSIONS
+// Widening multiply and multiply-accumulate
+#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD)
+DEF_NEON_FUNCTION (vmull, bhs_integer, ("Qd0,D0,D0"))
+DEF_NEON_FUNCTION (vmull_high, bhs_integer, ("Qd0,Q0,Q0"))
+DEF_NEON_FUNCTION (vmlal, bhs_integer, ("Qd0,Qd0,D0,D0"))
+DEF_NEON_FUNCTION (vmlal_high, bhs_integer, ("Qd0,Qd0,Q0,Q0"))
+DEF_NEON_FUNCTION (vmlsl, bhs_integer, ("Qd0,Qd0,D0,D0"))
+DEF_NEON_FUNCTION (vmlsl_high, bhs_integer, ("Qd0,Qd0,Q0,Q0"))
+#undef REQUIRED_EXTENSIONS
+
// Bitwise operations
#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD)
DEF_NEON_FUNCTION (vand, all_integer, ("D0,D0,D0"))
diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def
b/gcc/config/aarch64/aarch64-simd-builtins.def
index 0df54066b7a9..a3617da4d468 100644
--- a/gcc/config/aarch64/aarch64-simd-builtins.def
+++ b/gcc/config/aarch64/aarch64-simd-builtins.def
@@ -267,18 +267,10 @@
BUILTIN_VQN (SHIFT2IMM, rshrn2_n, 0, DEFAULT)
BUILTIN_VQN (USHIFT2IMM, rshrn2_n, 0, DEFAULT)
- /* Implemented by aarch64_<su>mlsl<mode>. */
- BUILTIN_VD_BHSI (TERNOP, smlsl, 0, DEFAULT)
- BUILTIN_VD_BHSI (TERNOPU, umlsl, 0, DEFAULT)
-
/* Implemented by aarch64_<su>mlsl_n<mode>. */
BUILTIN_VD_HSI (TERNOP, smlsl_n, 0, DEFAULT)
BUILTIN_VD_HSI (TERNOPU, umlsl_n, 0, DEFAULT)
- /* Implemented by aarch64_<su>mlal<mode>. */
- BUILTIN_VD_BHSI (TERNOP, smlal, 0, DEFAULT)
- BUILTIN_VD_BHSI (TERNOPU, umlal, 0, DEFAULT)
-
/* Implemented by aarch64_<su>mlal_n<mode>. */
BUILTIN_VD_HSI (TERNOP, smlal_n, 0, DEFAULT)
BUILTIN_VD_HSI (TERNOPU, umlal_n, 0, DEFAULT)
@@ -342,9 +334,6 @@
BUILTIN_VQ_HSI (TERNOP, sqdmlal2_n, 0, DEFAULT)
BUILTIN_VQ_HSI (TERNOP, sqdmlsl2_n, 0, DEFAULT)
- BUILTIN_VD_BHSI (BINOP, intrinsic_vec_smult_lo_, 0, DEFAULT)
- BUILTIN_VD_BHSI (BINOPU, intrinsic_vec_umult_lo_, 0, DEFAULT)
-
BUILTIN_VQW (BINOP, vec_widen_smult_hi_, 10, DEFAULT)
BUILTIN_VQW (BINOPU, vec_widen_umult_hi_, 10, DEFAULT)
diff --git a/gcc/config/aarch64/aarch64-simd.md
b/gcc/config/aarch64/aarch64-simd.md
index 6b4aff5e21e2..0bbdf54b5766 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -2408,7 +2408,7 @@
[(set_attr "type" "neon_mla_<Vetype>_long")]
)
-(define_expand "aarch64_<su>mlal_hi<mode>"
+(define_expand "@aarch64_<su>mlal_hi<mode>"
[(match_operand:<VWIDE> 0 "register_operand")
(match_operand:<VWIDE> 1 "register_operand")
(ANY_EXTEND:<VWIDE>(match_operand:VQW 2 "register_operand"))
@@ -2485,7 +2485,7 @@
[(set_attr "type" "neon_mla_<Vetype>_long")]
)
-(define_expand "aarch64_<su>mlsl_hi<mode>"
+(define_expand "@aarch64_<su>mlsl_hi<mode>"
[(match_operand:<VWIDE> 0 "register_operand")
(match_operand:<VWIDE> 1 "register_operand")
(ANY_EXTEND:<VWIDE>(match_operand:VQW 2 "register_operand"))
@@ -2530,7 +2530,7 @@
}
)
-(define_insn "aarch64_<su>mlal<mode>"
+(define_insn "@aarch64_<su>mlal<mode>"
[(set (match_operand:<VWIDE> 0 "register_operand" "=w")
(plus:<VWIDE>
(mult:<VWIDE>
@@ -2559,7 +2559,7 @@
[(set_attr "type" "neon_mla_<Vetype>_long")]
)
-(define_insn "aarch64_<su>mlsl<mode>"
+(define_insn "@aarch64_<su>mlsl<mode>"
[(set (match_operand:<VWIDE> 0 "register_operand" "=w")
(minus:<VWIDE>
(match_operand:<VWIDE> 1 "register_operand" "0")
@@ -2601,7 +2601,7 @@
[(set_attr "type" "neon_mul_<Vetype>_long")]
)
-(define_insn "aarch64_intrinsic_vec_<su>mult_lo_<mode>"
+(define_insn "@aarch64_intrinsic_vec_<su>mult_lo_<mode>"
[(set (match_operand:<VWIDE> 0 "register_operand" "=w")
(mult:<VWIDE> (ANY_EXTEND:<VWIDE>
(match_operand:VD_BHSI 1 "register_operand" "w"))
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc
b/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc
index 0af0d55366c4..a7cc390afd22 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc
@@ -112,6 +112,7 @@ apply_predication (function_instance &instance, tree
return_type,
f[01] - a floating-point type with the same width as type suffix 0 or 1
B - bfloat16_t
c - a predicate-as-counter
+ d<elt> - a double-sized version of <elt>
h<elt> - a half-sized version of <elt>
M - mfloat8_t
p - a predicate (represented as TYPE_SUFFIX_b)
@@ -168,6 +169,13 @@ parse_element_type (const function_instance &instance, const
char *&format)
type_suffixes[suffix].element_bits / 4);
}
+ if (ch == 'd')
+ {
+ type_suffix_index suffix = parse_element_type (instance, format);
+ return find_type_suffix (type_suffixes[suffix].tclass,
+ type_suffixes[suffix].element_bits * 2);
+ }
+
if (ch == 'h')
{
type_suffix_index suffix = parse_element_type (instance, format);
diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h
index 7b5926ca21b2..10a999ee7200 100644
--- a/gcc/config/aarch64/arm_neon.h
+++ b/gcc/config/aarch64/arm_neon.h
@@ -1907,48 +1907,6 @@ vmlal_high_n_u32 (uint64x2_t __a, uint32x4_t __b,
uint32_t __c)
return __builtin_aarch64_umlal_hi_nv4si_uuuu (__a, __b, __c);
}
-__extension__ extern __inline int16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_high_s8 (int16x8_t __a, int8x16_t __b, int8x16_t __c)
-{
- return __builtin_aarch64_smlal_hiv16qi (__a, __b, __c);
-}
-
-__extension__ extern __inline int32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_high_s16 (int32x4_t __a, int16x8_t __b, int16x8_t __c)
-{
- return __builtin_aarch64_smlal_hiv8hi (__a, __b, __c);
-}
-
-__extension__ extern __inline int64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_high_s32 (int64x2_t __a, int32x4_t __b, int32x4_t __c)
-{
- return __builtin_aarch64_smlal_hiv4si (__a, __b, __c);
-}
-
-__extension__ extern __inline uint16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_high_u8 (uint16x8_t __a, uint8x16_t __b, uint8x16_t __c)
-{
- return __builtin_aarch64_umlal_hiv16qi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_high_u16 (uint32x4_t __a, uint16x8_t __b, uint16x8_t __c)
-{
- return __builtin_aarch64_umlal_hiv8hi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_high_u32 (uint64x2_t __a, uint32x4_t __b, uint32x4_t __c)
-{
- return __builtin_aarch64_umlal_hiv4si_uuuu (__a, __b, __c);
-}
-
__extension__ extern __inline int32x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
vmlal_lane_s16 (int32x4_t __acc, int16x4_t __a, int16x4_t __b, const int __c)
@@ -2033,48 +1991,6 @@ vmlal_n_u32 (uint64x2_t __a, uint32x2_t __b, uint32_t
__c)
return __builtin_aarch64_umlal_nv2si_uuuu (__a, __b, __c);
}
-__extension__ extern __inline int16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_s8 (int16x8_t __a, int8x8_t __b, int8x8_t __c)
-{
- return __builtin_aarch64_smlalv8qi (__a, __b, __c);
-}
-
-__extension__ extern __inline int32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_s16 (int32x4_t __a, int16x4_t __b, int16x4_t __c)
-{
- return __builtin_aarch64_smlalv4hi (__a, __b, __c);
-}
-
-__extension__ extern __inline int64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_s32 (int64x2_t __a, int32x2_t __b, int32x2_t __c)
-{
- return __builtin_aarch64_smlalv2si (__a, __b, __c);
-}
-
-__extension__ extern __inline uint16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_u8 (uint16x8_t __a, uint8x8_t __b, uint8x8_t __c)
-{
- return __builtin_aarch64_umlalv8qi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_u16 (uint32x4_t __a, uint16x4_t __b, uint16x4_t __c)
-{
- return __builtin_aarch64_umlalv4hi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlal_u32 (uint64x2_t __a, uint32x2_t __b, uint32x2_t __c)
-{
- return __builtin_aarch64_umlalv2si_uuuu (__a, __b, __c);
-}
-
__extension__ extern __inline float32x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
vmlaq_n_f32 (float32x4_t __a, float32x4_t __b, float32_t __c)
@@ -2321,48 +2237,6 @@ vmlsl_high_n_u32 (uint64x2_t __a, uint32x4_t __b,
uint32_t __c)
return __builtin_aarch64_umlsl_hi_nv4si_uuuu (__a, __b, __c);
}
-__extension__ extern __inline int16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_high_s8 (int16x8_t __a, int8x16_t __b, int8x16_t __c)
-{
- return __builtin_aarch64_smlsl_hiv16qi (__a, __b, __c);
-}
-
-__extension__ extern __inline int32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_high_s16 (int32x4_t __a, int16x8_t __b, int16x8_t __c)
-{
- return __builtin_aarch64_smlsl_hiv8hi (__a, __b, __c);
-}
-
-__extension__ extern __inline int64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_high_s32 (int64x2_t __a, int32x4_t __b, int32x4_t __c)
-{
- return __builtin_aarch64_smlsl_hiv4si (__a, __b, __c);
-}
-
-__extension__ extern __inline uint16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_high_u8 (uint16x8_t __a, uint8x16_t __b, uint8x16_t __c)
-{
- return __builtin_aarch64_umlsl_hiv16qi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_high_u16 (uint32x4_t __a, uint16x8_t __b, uint16x8_t __c)
-{
- return __builtin_aarch64_umlsl_hiv8hi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_high_u32 (uint64x2_t __a, uint32x4_t __b, uint32x4_t __c)
-{
- return __builtin_aarch64_umlsl_hiv4si_uuuu (__a, __b, __c);
-}
-
__extension__ extern __inline int32x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
vmlsl_lane_s16 (int32x4_t __a, int16x4_t __b, int16x4_t __v, const int __lane)
@@ -2451,48 +2325,6 @@ vmlsl_n_u32 (uint64x2_t __a, uint32x2_t __b, uint32_t
__c)
return __builtin_aarch64_umlsl_nv2si_uuuu (__a, __b, __c);
}
-__extension__ extern __inline int16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_s8 (int16x8_t __a, int8x8_t __b, int8x8_t __c)
-{
- return __builtin_aarch64_smlslv8qi (__a, __b, __c);
-}
-
-__extension__ extern __inline int32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_s16 (int32x4_t __a, int16x4_t __b, int16x4_t __c)
-{
- return __builtin_aarch64_smlslv4hi (__a, __b, __c);
-}
-
-__extension__ extern __inline int64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_s32 (int64x2_t __a, int32x2_t __b, int32x2_t __c)
-{
- return __builtin_aarch64_smlslv2si (__a, __b, __c);
-}
-
-__extension__ extern __inline uint16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_u8 (uint16x8_t __a, uint8x8_t __b, uint8x8_t __c)
-{
- return __builtin_aarch64_umlslv8qi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_u16 (uint32x4_t __a, uint16x4_t __b, uint16x4_t __c)
-{
- return __builtin_aarch64_umlslv4hi_uuuu (__a, __b, __c);
-}
-
-__extension__ extern __inline uint64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmlsl_u32 (uint64x2_t __a, uint32x2_t __b, uint32x2_t __c)
-{
- return __builtin_aarch64_umlslv2si_uuuu (__a, __b, __c);
-}
-
__extension__ extern __inline float32x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
vmlsq_n_f32 (float32x4_t __a, float32x4_t __b, float32_t __c)
@@ -2871,48 +2703,6 @@ vmull_high_p8 (poly8x16_t __a, poly8x16_t __b)
return __builtin_aarch64_pmull_hiv16qi_ppp (__a, __b);
}
-__extension__ extern __inline int16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_high_s8 (int8x16_t __a, int8x16_t __b)
-{
- return __builtin_aarch64_vec_widen_smult_hi_v16qi (__a, __b);
-}
-
-__extension__ extern __inline int32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_high_s16 (int16x8_t __a, int16x8_t __b)
-{
- return __builtin_aarch64_vec_widen_smult_hi_v8hi (__a, __b);
-}
-
-__extension__ extern __inline int64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_high_s32 (int32x4_t __a, int32x4_t __b)
-{
- return __builtin_aarch64_vec_widen_smult_hi_v4si (__a, __b);
-}
-
-__extension__ extern __inline uint16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_high_u8 (uint8x16_t __a, uint8x16_t __b)
-{
- return __builtin_aarch64_vec_widen_umult_hi_v16qi_uuu (__a, __b);
-}
-
-__extension__ extern __inline uint32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_high_u16 (uint16x8_t __a, uint16x8_t __b)
-{
- return __builtin_aarch64_vec_widen_umult_hi_v8hi_uuu (__a, __b);
-}
-
-__extension__ extern __inline uint64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_high_u32 (uint32x4_t __a, uint32x4_t __b)
-{
- return __builtin_aarch64_vec_widen_umult_hi_v4si_uuu (__a, __b);
-}
-
__extension__ extern __inline int32x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
vmull_lane_s16 (int16x4_t __a, int16x4_t __b, const int __c)
@@ -3004,48 +2794,6 @@ vmull_p8 (poly8x8_t __a, poly8x8_t __b)
return __builtin_aarch64_pmullv8qi_ppp (__a, __b);
}
-__extension__ extern __inline int16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_s8 (int8x8_t __a, int8x8_t __b)
-{
- return __builtin_aarch64_intrinsic_vec_smult_lo_v8qi (__a, __b);
-}
-
-__extension__ extern __inline int32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_s16 (int16x4_t __a, int16x4_t __b)
-{
- return __builtin_aarch64_intrinsic_vec_smult_lo_v4hi (__a, __b);
-}
-
-__extension__ extern __inline int64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_s32 (int32x2_t __a, int32x2_t __b)
-{
- return __builtin_aarch64_intrinsic_vec_smult_lo_v2si (__a, __b);
-}
-
-__extension__ extern __inline uint16x8_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_u8 (uint8x8_t __a, uint8x8_t __b)
-{
- return __builtin_aarch64_intrinsic_vec_umult_lo_v8qi_uuu (__a, __b);
-}
-
-__extension__ extern __inline uint32x4_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_u16 (uint16x4_t __a, uint16x4_t __b)
-{
- return __builtin_aarch64_intrinsic_vec_umult_lo_v4hi_uuu (__a, __b);
-}
-
-__extension__ extern __inline uint64x2_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-vmull_u32 (uint32x2_t __a, uint32x2_t __b)
-{
- return __builtin_aarch64_intrinsic_vec_umult_lo_v2si_uuu (__a, __b);
-}
-
__extension__ extern __inline int16x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
vpadal_s8 (int16x4_t __a, int8x8_t __b)
diff --git a/gcc/testsuite/gcc.target/aarch64/neon/discarded_result.c
b/gcc/testsuite/gcc.target/aarch64/neon/discarded_result.c
index 1adec7fe8d3b..86c28841fb8d 100644
--- a/gcc/testsuite/gcc.target/aarch64/neon/discarded_result.c
+++ b/gcc/testsuite/gcc.target/aarch64/neon/discarded_result.c
@@ -14,3 +14,66 @@ void foo(float32x2_t a, float32x2_t b)
{
vadd_f32 (a, b);
}
+
+/*
+** test_vmull_s8:
+** ret
+*/
+void test_vmull_s8 (int8x8_t a, int8x8_t b)
+{
+ vmull_s8 (a, b);
+}
+
+/*
+** test_vmull_high_s16:
+** ret
+*/
+void test_vmull_high_s16 (int16x8_t a, int16x8_t b)
+{
+ vmull_high_s16 (a, b);
+}
+
+/*
+** test_vmull_s32:
+** ret
+*/
+void test_vmull_s32 (int32x2_t a, int32x2_t b)
+{
+ vmull_s32 (a, b);
+}
+
+/*
+** test_vmlal_u8:
+** ret
+*/
+void test_vmlal_u8 (uint16x8_t acc, uint8x8_t a, uint8x8_t b)
+{
+ vmlal_u8 (acc, a, b);
+}
+
+/*
+** test_vmlsl_high_s16:
+** ret
+*/
+void test_vmlsl_high_s16 (int32x4_t acc, int16x8_t a, int16x8_t b)
+{
+ vmlsl_high_s16 (acc, a, b);
+}
+
+/*
+** test_vmull_high_redirect:
+** ret
+*/
+void test_vmull_high_redirect (int32x4_t x, int32x4_t y)
+{
+ vmull_s32 (vget_high_s32 (x), vget_high_s32 (y));
+}
+
+/*
+** test_vmull_splat_redirect:
+** ret
+*/
+void test_vmull_splat_redirect (int8x16_t x)
+{
+ vmull_s8 (vget_high_s8 (x), vdup_n_s8 (3));
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vmlal.c
b/gcc/testsuite/gcc.target/aarch64/neon/vmlal.c
new file mode 100644
index 000000000000..1466631a9595
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/neon/vmlal.c
@@ -0,0 +1,102 @@
+/* { dg-do compile } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "arm_neon_test.h"
+
+/*
+** test_vmlal_u8:
+** umlal v0\.8h, (v1\.8b, v2\.8b|v2\.8b, v1\.8b)
+** ret
+*/
+TEST_TERNARY (vmlal_u8, uint16x8_t, uint16x8_t, uint8x8_t, uint8x8_t)
+
+/*
+** test_vmlal_high_u8:
+** umlal2 v0\.8h, (v1\.16b, v2\.16b|v2\.16b, v1\.16b)
+** ret
+*/
+TEST_TERNARY (vmlal_high_u8, uint16x8_t, uint16x8_t, uint8x16_t, uint8x16_t)
+
+/*
+** test_vmlal_s8:
+** smlal v0\.8h, (v1\.8b, v2\.8b|v2\.8b, v1\.8b)
+** ret
+*/
+TEST_TERNARY (vmlal_s8, int16x8_t, int16x8_t, int8x8_t, int8x8_t)
+
+/*
+** test_vmlal_high_s8:
+** smlal2 v0\.8h, (v1\.16b, v2\.16b|v2\.16b, v1\.16b)
+** ret
+*/
+TEST_TERNARY (vmlal_high_s8, int16x8_t, int16x8_t, int8x16_t, int8x16_t)
+
+/*
+** test_vmlal_u16:
+** umlal v0\.4s, (v1\.4h, v2\.4h|v2\.4h, v1\.4h)
+** ret
+*/
+TEST_TERNARY (vmlal_u16, uint32x4_t, uint32x4_t, uint16x4_t, uint16x4_t)
+
+/*
+** test_vmlal_high_u16:
+** umlal2 v0\.4s, (v1\.8h, v2\.8h|v2\.8h, v1\.8h)
+** ret
+*/
+TEST_TERNARY (vmlal_high_u16, uint32x4_t, uint32x4_t, uint16x8_t, uint16x8_t)
+
+/*
+** test_vmlal_s16:
+** smlal v0\.4s, (v1\.4h, v2\.4h|v2\.4h, v1\.4h)
+** ret
+*/
+TEST_TERNARY (vmlal_s16, int32x4_t, int32x4_t, int16x4_t, int16x4_t)
+
+/*
+** test_vmlal_high_s16:
+** smlal2 v0\.4s, (v1\.8h, v2\.8h|v2\.8h, v1\.8h)
+** ret
+*/
+TEST_TERNARY (vmlal_high_s16, int32x4_t, int32x4_t, int16x8_t, int16x8_t)
+
+/*
+** test_vmlal_u32:
+** umlal v0\.2d, (v1\.2s, v2\.2s|v2\.2s, v1\.2s)
+** ret
+*/
+TEST_TERNARY (vmlal_u32, uint64x2_t, uint64x2_t, uint32x2_t, uint32x2_t)
+
+/*
+** test_vmlal_high_u32:
+** umlal2 v0\.2d, (v1\.4s, v2\.4s|v2\.4s, v1\.4s)
+** ret
+*/
+TEST_TERNARY (vmlal_high_u32, uint64x2_t, uint64x2_t, uint32x4_t, uint32x4_t)
+
+/*
+** test_vmlal_s32:
+** smlal v0\.2d, (v1\.2s, v2\.2s|v2\.2s, v1\.2s)
+** ret
+*/
+TEST_TERNARY (vmlal_s32, int64x2_t, int64x2_t, int32x2_t, int32x2_t)
+
+/*
+** test_vmlal_high_s32:
+** smlal2 v0\.2d, (v1\.4s, v2\.4s|v2\.4s, v1\.4s)
+** ret
+*/
+TEST_TERNARY (vmlal_high_s32, int64x2_t, int64x2_t, int32x4_t, int32x4_t)
+
+/* Both multiplicands are upper halves, so the fold uses the high form rather
+ than extracting them. */
+
+/*
+** test_vmlal_both_high:
+** smlal2 v0\.2d, (v1\.4s, v2\.4s|v2\.4s, v1\.4s)
+** ret
+*/
+int64x2_t
+test_vmlal_both_high (int64x2_t acc, int32x4_t a, int32x4_t b)
+{
+ return vmlal_s32 (acc, vget_high_s32 (a), vget_high_s32 (b));
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vmlsl.c
b/gcc/testsuite/gcc.target/aarch64/neon/vmlsl.c
new file mode 100644
index 000000000000..c4f433e6e54d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/neon/vmlsl.c
@@ -0,0 +1,88 @@
+/* { dg-do compile } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "arm_neon_test.h"
+
+/*
+** test_vmlsl_u8:
+** umlsl v0\.8h, (v1\.8b, v2\.8b|v2\.8b, v1\.8b)
+** ret
+*/
+TEST_TERNARY (vmlsl_u8, uint16x8_t, uint16x8_t, uint8x8_t, uint8x8_t)
+
+/*
+** test_vmlsl_high_u8:
+** umlsl2 v0\.8h, (v1\.16b, v2\.16b|v2\.16b, v1\.16b)
+** ret
+*/
+TEST_TERNARY (vmlsl_high_u8, uint16x8_t, uint16x8_t, uint8x16_t, uint8x16_t)
+
+/*
+** test_vmlsl_s8:
+** smlsl v0\.8h, (v1\.8b, v2\.8b|v2\.8b, v1\.8b)
+** ret
+*/
+TEST_TERNARY (vmlsl_s8, int16x8_t, int16x8_t, int8x8_t, int8x8_t)
+
+/*
+** test_vmlsl_high_s8:
+** smlsl2 v0\.8h, (v1\.16b, v2\.16b|v2\.16b, v1\.16b)
+** ret
+*/
+TEST_TERNARY (vmlsl_high_s8, int16x8_t, int16x8_t, int8x16_t, int8x16_t)
+
+/*
+** test_vmlsl_u16:
+** umlsl v0\.4s, (v1\.4h, v2\.4h|v2\.4h, v1\.4h)
+** ret
+*/
+TEST_TERNARY (vmlsl_u16, uint32x4_t, uint32x4_t, uint16x4_t, uint16x4_t)
+
+/*
+** test_vmlsl_high_u16:
+** umlsl2 v0\.4s, (v1\.8h, v2\.8h|v2\.8h, v1\.8h)
+** ret
+*/
+TEST_TERNARY (vmlsl_high_u16, uint32x4_t, uint32x4_t, uint16x8_t, uint16x8_t)
+
+/*
+** test_vmlsl_s16:
+** smlsl v0\.4s, (v1\.4h, v2\.4h|v2\.4h, v1\.4h)
+** ret
+*/
+TEST_TERNARY (vmlsl_s16, int32x4_t, int32x4_t, int16x4_t, int16x4_t)
+
+/*
+** test_vmlsl_high_s16:
+** smlsl2 v0\.4s, (v1\.8h, v2\.8h|v2\.8h, v1\.8h)
+** ret
+*/
+TEST_TERNARY (vmlsl_high_s16, int32x4_t, int32x4_t, int16x8_t, int16x8_t)
+
+/*
+** test_vmlsl_u32:
+** umlsl v0\.2d, (v1\.2s, v2\.2s|v2\.2s, v1\.2s)
+** ret
+*/
+TEST_TERNARY (vmlsl_u32, uint64x2_t, uint64x2_t, uint32x2_t, uint32x2_t)
+
+/*
+** test_vmlsl_high_u32:
+** umlsl2 v0\.2d, (v1\.4s, v2\.4s|v2\.4s, v1\.4s)
+** ret
+*/
+TEST_TERNARY (vmlsl_high_u32, uint64x2_t, uint64x2_t, uint32x4_t, uint32x4_t)
+
+/*
+** test_vmlsl_s32:
+** smlsl v0\.2d, (v1\.2s, v2\.2s|v2\.2s, v1\.2s)
+** ret
+*/
+TEST_TERNARY (vmlsl_s32, int64x2_t, int64x2_t, int32x2_t, int32x2_t)
+
+/*
+** test_vmlsl_high_s32:
+** smlsl2 v0\.2d, (v1\.4s, v2\.4s|v2\.4s, v1\.4s)
+** ret
+*/
+TEST_TERNARY (vmlsl_high_s32, int64x2_t, int64x2_t, int32x4_t, int32x4_t)
diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vmull.c
b/gcc/testsuite/gcc.target/aarch64/neon/vmull.c
new file mode 100644
index 000000000000..3603d44683a6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/neon/vmull.c
@@ -0,0 +1,131 @@
+/* { dg-do compile } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "arm_neon_test.h"
+
+/*
+** test_vmull_u8:
+** umull v0\.8h, (v0\.8b, v1\.8b|v1\.8b, v0\.8b)
+** ret
+*/
+TEST_BINARY (vmull_u8, uint16x8_t, uint8x8_t, uint8x8_t)
+
+/*
+** test_vmull_high_u8:
+** umull2 v0\.8h, (v0\.16b, v1\.16b|v1\.16b, v0\.16b)
+** ret
+*/
+TEST_BINARY (vmull_high_u8, uint16x8_t, uint8x16_t, uint8x16_t)
+
+/*
+** test_vmull_s8:
+** smull v0\.8h, (v0\.8b, v1\.8b|v1\.8b, v0\.8b)
+** ret
+*/
+TEST_BINARY (vmull_s8, int16x8_t, int8x8_t, int8x8_t)
+
+/*
+** test_vmull_high_s8:
+** smull2 v0\.8h, (v0\.16b, v1\.16b|v1\.16b, v0\.16b)
+** ret
+*/
+TEST_BINARY (vmull_high_s8, int16x8_t, int8x16_t, int8x16_t)
+
+/*
+** test_vmull_u16:
+** umull v0\.4s, (v0\.4h, v1\.4h|v1\.4h, v0\.4h)
+** ret
+*/
+TEST_BINARY (vmull_u16, uint32x4_t, uint16x4_t, uint16x4_t)
+
+/*
+** test_vmull_high_u16:
+** umull2 v0\.4s, (v0\.8h, v1\.8h|v1\.8h, v0\.8h)
+** ret
+*/
+TEST_BINARY (vmull_high_u16, uint32x4_t, uint16x8_t, uint16x8_t)
+
+/*
+** test_vmull_s16:
+** smull v0\.4s, (v0\.4h, v1\.4h|v1\.4h, v0\.4h)
+** ret
+*/
+TEST_BINARY (vmull_s16, int32x4_t, int16x4_t, int16x4_t)
+
+/*
+** test_vmull_high_s16:
+** smull2 v0\.4s, (v0\.8h, v1\.8h|v1\.8h, v0\.8h)
+** ret
+*/
+TEST_BINARY (vmull_high_s16, int32x4_t, int16x8_t, int16x8_t)
+
+/*
+** test_vmull_u32:
+** umull v0\.2d, (v0\.2s, v1\.2s|v1\.2s, v0\.2s)
+** ret
+*/
+TEST_BINARY (vmull_u32, uint64x2_t, uint32x2_t, uint32x2_t)
+
+/*
+** test_vmull_high_u32:
+** umull2 v0\.2d, (v0\.4s, v1\.4s|v1\.4s, v0\.4s)
+** ret
+*/
+TEST_BINARY (vmull_high_u32, uint64x2_t, uint32x4_t, uint32x4_t)
+
+/*
+** test_vmull_s32:
+** smull v0\.2d, (v0\.2s, v1\.2s|v1\.2s, v0\.2s)
+** ret
+*/
+TEST_BINARY (vmull_s32, int64x2_t, int32x2_t, int32x2_t)
+
+/*
+** test_vmull_high_s32:
+** smull2 v0\.2d, (v0\.4s, v1\.4s|v1\.4s, v0\.4s)
+** ret
+*/
+TEST_BINARY (vmull_high_s32, int64x2_t, int32x4_t, int32x4_t)
+
+/* A low form call whose operands are an upper half and a constant or splat
+ redirects to the high form. */
+
+/*
+** test_vmull_high_cst:
+** movi v([0-9]+)\.16b, 0x3
+** smull2 v0\.8h, v0\.16b, v\1\.16b
+** ret
+*/
+int16x8_t
+test_vmull_high_cst (int8x16_t a)
+{
+ return vmull_s8 (vget_high_s8 (a), vdup_n_s8 (3));
+}
+
+/*
+** test_vmull_high_splat:
+** dup v([0-9]+)\.16b, w0
+** smull2 v0\.8h, v0\.16b, v\1\.16b
+** ret
+*/
+int16x8_t
+test_vmull_high_splat (int8x16_t a, int8_t b)
+{
+ return vmull_s8 (vget_high_s8 (a), vdup_n_s8 (b));
+}
+
+/* A constant that reaches the call through a declaration is only recognisable
+ once the function is in SSA form. */
+
+/*
+** test_vmull_cst_decl:
+** movi v([0-9]+)\.4h, 0x3
+** smull v0\.4s, v0\.4h, v\1\.4h
+** ret
+*/
+int32x4_t
+test_vmull_cst_decl (int16x4_t a)
+{
+ int16x4_t b = vdup_n_s16 (3);
+ return vmull_s16 (a, b);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_1.c
b/gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_1.c
index f082198b54bc..b5b261d64a26 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_1.c
@@ -567,25 +567,25 @@ TEST_VMLAL_N
/*
** test_vmlsl_s8:
-** smlsl2 v0\.8h, v1\.16b, v2\.16b
+** smlsl2 v0\.8h, (v1\.16b, v2\.16b|v2\.16b, v1\.16b)
** ret
*/
/*
** test_vmlsl_u8:
-** umlsl2 v0\.8h, v1\.16b, v2\.16b
+** umlsl2 v0\.8h, (v1\.16b, v2\.16b|v2\.16b, v1\.16b)
** ret
*/
/*
** test_vmlsl_s16:
-** smlsl2 v0\.4s, v1\.8h, v2\.8h
+** smlsl2 v0\.4s, (v1\.8h, v2\.8h|v2\.8h, v1\.8h)
** ret
*/
/*
** test_vmlsl_u16:
-** umlsl2 v0\.4s, v1\.8h, v2\.8h
+** umlsl2 v0\.4s, (v1\.8h, v2\.8h|v2\.8h, v1\.8h)
** ret
*/
--
2.43.0