On 06/11/26 17:29, Kyrylo Tkachov wrote:
Hi Dhruv,

On 26 Oct 2026, at 09:47, Dhruv Chawla <[email protected]> wrote:

From: Dhruv Chawla <[email protected]>

Note: This patch requires a fix for PR127771 to have a clean
bootstrap+regtest. It was tested with one such fix in place.

--- >8 ---

Port the following intrinsics to the pragma-based framework:
* vmull
* vmlal
* vmlsl

Folding is left until the function is in SSA form. Before that a constant
operand is still an unresolved declaration which is indistinguishable from a
variable, and folding one would widen it to the result type where no
widening instruction matches it any more.

This leads to an ICE in gimple_folder::force_val which needs a related fix
to PR127771 post-SSA with creating temporaries using make_ssa_name instead of
create_tmp_var. This can only be done for register types.

The fold handles the following forms that the widening intrinsics need:
- both multiplicands are the upper halves of 128-bit vectors: redirect to
   the high form.
- one multiplicand is a constant: redirect to the high form when that saves
   extracting a half, otherwise decline.
- exactly one multiplicand is an upper half: decline, so that expand sees the
   extraction rather than an SXTL2 and a plain multiply.

Add a `d<elt>` element-type character alongside `h<elt>` and `q<elt>` so the
signatures can name a type twice as wide as the type suffix.

Some notes:
- The accumulation for vmlal and vmlsl is done in the unsigned type so that
   signed overflow wraps as the ACLE requires.
- The 32-bit forms cannot be folded. AArch64 has no vector multiply for
   64-bit elements, eg. `(int64x2_t) a * (int64x2_t) b` would only be
   scalarised again so those rely on expand instead.

vmull_p8, vmull_p64 and their _high forms map to PMULL rather than a
widening multiply, and are left in arm_neon.h.

Bootstrapped and regtested on aarch64-linux-gnu.

Signed-off-by: Dhruv Chawla <[email protected]>

gcc/ChangeLog:

* config/aarch64/aarch64-acle-builtins.cc (gimple_folder::force_val):
Make an SSA name for the temporary when is_gimple_reg_type.
* config/aarch64/aarch64-builtin-pairs.def (BINOP_LONG_LH_PAIRS,
TERNOP_LONG_LH_PAIRS): Drop the pairs for the ported intrinsics.
* config/aarch64/aarch64-builtins.cc (aarch64_v128_highpart_src_reg):
New function.
(aarch64_fold_lo_call_to_hi): Use it.
(aarch64_build_vector_cst): Make non-static.
* config/aarch64/aarch64-builtins.h (aarch64_v128_highpart_src_reg,
aarch64_build_vector_cst): Declare.
* config/aarch64/aarch64-neon-builtins-base.cc: Include
aarch64-builtins.h and aarch64-neon-builtins-shapes.h.
(build_vec_extract_half): New function.
(gimple_get_half::fold): Use it.
(gimple_widen_mult): New class.
(vmull, vmull_high, vmlal, vmlal_high, vmlsl, vmlsl_high): New
function bases.
* config/aarch64/aarch64-neon-builtins-base.def (vmull, vmull_high,
vmlal, vmlal_high, vmlsl, vmlsl_high): New function groups.
* config/aarch64/aarch64-simd-builtins.def (smlal, umlal, smlsl,
umlsl, intrinsic_vec_smult_lo_, intrinsic_vec_umult_lo_): Delete,
now that nothing expands to them.
* config/aarch64/aarch64-simd.md
(@aarch64_intrinsic_vec_<su>mult_lo_<mode>, @aarch64_<su>mlal<mode>,
@aarch64_<su>mlsl<mode>, @aarch64_<su>mlal_hi<mode>,
@aarch64_<su>mlsl_hi<mode>): Rename from the unprefixed forms so
that they can be selected by mode.
* config/aarch64/aarch64-sve-builtins-shapes.cc (parse_element_type):
Handle `d<elt>`.
* config/aarch64/arm_neon.h (vmlal_high_s8, vmlal_high_s16,
vmlal_high_s32, vmlal_high_u8, vmlal_high_u16, vmlal_high_u32,
vmlal_s8, vmlal_s16, vmlal_s32, vmlal_u8, vmlal_u16, vmlal_u32,
vmlsl_high_s8, vmlsl_high_s16, vmlsl_high_s32, vmlsl_high_u8,
vmlsl_high_u16, vmlsl_high_u32, vmlsl_s8, vmlsl_s16, vmlsl_s32,
vmlsl_u8, vmlsl_u16, vmlsl_u32, vmull_high_s8, vmull_high_s16,
vmull_high_s32, vmull_high_u8, vmull_high_u16, vmull_high_u32,
vmull_s8, vmull_s16, vmull_s32, vmull_u8, vmull_u16, vmull_u32):
Delete functions.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/neon/discarded_result.c (test_vmull_s8,
test_vmull_high_s16, test_vmull_s32, test_vmlal_u8,
test_vmlsl_high_s16, test_vmull_high_redirect,
test_vmull_splat_redirect): New functions.
* gcc.target/aarch64/neon/vmlal.c: New test.
* gcc.target/aarch64/neon/vmlsl.c: Likewise.
* gcc.target/aarch64/neon/vmull.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_1.c: Allow either operand
order for vmlsl, which GIMPLE is free to commute.
---
gcc/config/aarch64/aarch64-acle-builtins.cc   |   4 +-
gcc/config/aarch64/aarch64-builtin-pairs.def  |   4 -
gcc/config/aarch64/aarch64-builtins.cc        |  14 +-
gcc/config/aarch64/aarch64-builtins.h         |   5 +
.../aarch64/aarch64-neon-builtins-base.cc     | 228 +++++++++++++++-
.../aarch64/aarch64-neon-builtins-base.def    |  10 +
gcc/config/aarch64/aarch64-simd-builtins.def  |  11 -
gcc/config/aarch64/aarch64-simd.md            |  10 +-
.../aarch64/aarch64-sve-builtins-shapes.cc    |   8 +
gcc/config/aarch64/arm_neon.h                 | 252 ------------------
.../aarch64/neon/discarded_result.c           |  63 +++++
gcc/testsuite/gcc.target/aarch64/neon/vmlal.c | 102 +++++++
gcc/testsuite/gcc.target/aarch64/neon/vmlsl.c |  88 ++++++
gcc/testsuite/gcc.target/aarch64/neon/vmull.c | 131 +++++++++
.../aarch64/simd/fold_to_highpart_1.c         |   8 +-
15 files changed, 655 insertions(+), 283 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vmlal.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vmlsl.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vmull.c

diff --git a/gcc/config/aarch64/aarch64-acle-builtins.cc 
b/gcc/config/aarch64/aarch64-acle-builtins.cc
index 2d52443a68ca..131d31efc89a 100644
--- a/gcc/config/aarch64/aarch64-acle-builtins.cc
+++ b/gcc/config/aarch64/aarch64-acle-builtins.cc
@@ -3159,7 +3159,9 @@ gimple_folder::force_val (tree expr)
     return expr;

   auto type = TREE_TYPE (expr);
-  auto var = create_tmp_var (type);
+  /* PR target/127771.  */
+  auto var
+    = is_gimple_reg_type (type) ? make_ssa_name (type) : create_tmp_var (type);
   auto stmt = gimple_build_assign (var, expr);
   gimple_seq_add_stmt_without_update (&stmts, stmt);
   return var;
diff --git a/gcc/config/aarch64/aarch64-builtin-pairs.def 
b/gcc/config/aarch64/aarch64-builtin-pairs.def
index 77d61cdd55c6..f86b2a9acb08 100644
--- a/gcc/config/aarch64/aarch64-builtin-pairs.def
+++ b/gcc/config/aarch64/aarch64-builtin-pairs.def
@@ -47,8 +47,6 @@
   LO_HI_PAIR_V_US_WI (BINOP,  addl, addl2) \
   LO_HI_PAIR_V_US_WI (BINOP,  subl, subl2) \
   LO_HI_PAIR_V_US_WI (BINOP,  abdl, abdl2) \
-  LO_HI_PAIR_V_WI (BINOP,  intrinsic_vec_smult_lo_, vec_widen_smult_hi_) \
-  LO_HI_PAIR_V_WI (BINOPU, intrinsic_vec_umult_lo_, vec_widen_umult_hi_) \
   LO_HI_PAIR_V_HSI (BINOP,  sqdmull, sqdmull2) \
   LO_HI_PAIR (BINOPP_pmullv8qi, BINOPP_pmull_hiv16qi)

@@ -61,8 +59,6 @@
   LO_HI_PAIR_V_US_WI (BINOP,  addw, addw2)

#define TERNOP_LONG_LH_PAIRS \
-  LO_HI_PAIR_V_US_WI (TERNOP,  mlal, mlal_hi) \
-  LO_HI_PAIR_V_US_WI (TERNOP,  mlsl, mlsl_hi) \
   LO_HI_PAIR_V_US_WI (TERNOP,  abal, abal2) \
   LO_HI_PAIR_V_HSI (TERNOP, sqdmlal, sqdmlal2) \
   LO_HI_PAIR_V_HSI (TERNOP, sqdmlsl, sqdmlsl2)
diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index fd7020049764..78bb921ce651 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -5054,9 +5054,18 @@ aarch64_v128_highpart_ref (const_tree ref)
   return NULL_TREE;
}

+/* Like aarch64_v128_highpart_ref, but only return the vector when it is a
+   register.  */
+tree
+aarch64_v128_highpart_src_reg (const_tree ref)
+{
+  tree obj = aarch64_v128_highpart_ref (ref);
+  return obj && is_gimple_reg (obj) ? obj : NULL_TREE;
+}
+
/* Build and return a new VECTOR_CST of type OUT_TY, using repeated
    copies of the elements of VEC_IN.  */
-static tree
+tree
aarch64_build_vector_cst (const_tree vec_in, tree out_ty)
{
   gcc_assert (TREE_CODE (vec_in) == VECTOR_CST
@@ -5123,8 +5132,7 @@ aarch64_fold_lo_call_to_hi (unsigned int fcode, gcall 
*stmt,
  gcc_assert (wi::to_widest (TYPE_SIZE (type_lo)) == 64
      && wi::to_widest (TYPE_SIZE (type_hi)) == 128);

-  tree vq = aarch64_v128_highpart_ref (arg);
-  if (vq && is_gimple_reg (vq))
+  if (auto vq = aarch64_v128_highpart_src_reg (arg))
    {
      vec_highparts.safe_push (argno);
      arg = vq;
diff --git a/gcc/config/aarch64/aarch64-builtins.h 
b/gcc/config/aarch64/aarch64-builtins.h
index 87fc0dcb2d57..97928dff5358 100644
--- a/gcc/config/aarch64/aarch64-builtins.h
+++ b/gcc/config/aarch64/aarch64-builtins.h
@@ -110,4 +110,9 @@ extern const aarch64_simd_type_info aarch64_simd_types[];
extern aarch64_simd_type_info_trees aarch64_simd_types_trees[];
extern tree aarch64_simd_tuple_types[ARM_NEON_H_TYPES_LAST][3];

+/* Shared with the pragma-based builtin folders, which do the same
+   lo-to-high-form rewriting for the families they have taken over.  */
+extern tree aarch64_v128_highpart_src_reg (const_tree);
+extern tree aarch64_build_vector_cst (const_tree, tree);
+
#endif
diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.cc 
b/gcc/config/aarch64/aarch64-neon-builtins-base.cc
index b00aed7c7d77..735a41bddafb 100644
--- a/gcc/config/aarch64/aarch64-neon-builtins-base.cc
+++ b/gcc/config/aarch64/aarch64-neon-builtins-base.cc
@@ -39,9 +39,11 @@
#include "tree-vector-builder.h"
#include "rtx-vector-builder.h"
#include "vec-perm-indices.h"
+#include "aarch64-builtins.h"
#include "aarch64-acle-builtins.h"
#include "aarch64-neon-builtins-base.h"
#include "aarch64-neon-builtins-functions.h"
+#include "aarch64-neon-builtins-shapes.h"
#include "gimple-fold.h"

namespace aarch64_acle {
@@ -97,6 +99,16 @@ build_lane_set (tree vec, tree index, tree elem)
   return fold_build3 (BIT_INSERT_EXPR, vec_type, vec, elem, offset);
}

+/* Build an extract of type TYPE (which must be a 64-bit vector type) for half
+   of the 128-bit vector VEC.  HIGH_P selects the upper half.  */
+tree
+build_vec_extract_half (tree type, tree vec, bool high_p)
+{
+  gcc_assert (known_eq (GET_MODE_BITSIZE (TYPE_MODE (type)), 64));
+  return fold_build3 (BIT_FIELD_REF, type, vec, bitsize_int (64),
+      bitsize_int (high_p ^ BYTES_BIG_ENDIAN ? 64 : 0));
+}
+
/* Build an expression for a vector with all lanes set to `ELEM`.  */
tree
build_vec_dup (tree type, tree elem)
@@ -272,9 +284,7 @@ struct gimple_get_half : public gimple_function_base
   gimple *fold (gimple_folder &f) const override
   {
     auto src = gimple_call_arg (f.call, 0);
-    auto half
-      = fold_build3 (BIT_FIELD_REF, TREE_TYPE (f.lhs), src, bitsize_int (64),
-     bitsize_int (high_half_p ^ BYTES_BIG_ENDIAN ? 64 : 0));
+    auto half = build_vec_extract_half (TREE_TYPE (f.lhs), src, high_half_p);
     return gimple_build_assign (f.lhs, half);
   }
};
@@ -764,6 +774,204 @@ struct gimple_reinterpret : public gimple_function_base
   }
};

+/* Widening multiply with optional accumulator.  HIGH_P selects the high forms,
+   usually spelled as `<name>_high`, eg. vmlsl_high.  */
+template <bool high_p> class gimple_widen_mult : public gimple_function_base
+{
+  struct high_form
+  {
+    const char *name;
+    const function_base *const *base;
+    const function_shape *const *shape;
+  };
+
+  /* The following intrinsics are mapped to GIMPLE here:
+      - VMLAL: PLUS_EXPR
+      - VMLSL: MINUS_EXPR
+      - VMULL: ERROR_MARK.  */

This looks odd, using ERROR_MARK to signify a mult while the accumulating forms 
get “normal” tree codes, especially as the class is named after a mult.
If the m_code really doesn’t matter beyond just being a 3-way selector then 
better to make it an enum that properly self-documents the operation (some form 
of MULT, PLUS_ACCUM, MINUS_ACCUM) and use that.

Otherwise the patch looks good.

Thanks Kyrill, made the changes and committed as r17-6385-g6ca86820d5e01f.

Thanks,
Kyrill

+  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




--
Regards,
Dhruv

Reply via email to