On Thu, Nov 05, 2026 at 03:47:20PM +0000, Alex Coplan wrote:
> Hi Ezra,
>
> On 28/10/2026 22:51, Ezra Sitorus wrote:
> > Add the AdvSIMD vmmlaq_f16 and vmmlaq_f32_f16 intrinsics, together with
> > the SVE svmmla_f16 and svmmla_bf16 forms and their overloaded aliases.
> >
> > This patch also requires this fix in binutils:
> > https://inbox.sourceware.org/binutils/[email protected]/
> >
> > gcc/ChangeLog:
>
> > Add new __ARM_FEATURE__ macros.
> > * config/aarch64/aarch64-neon-builtins-base.cc (vmmlaq_impl):
> > New function_base class.
> > (vmmlaq): Define new function base.
> > * config/aarch64/aarch64-neon-builtins-base.def (vmmlaq): Define
> > new NEON function.
> > * config/aarch64/aarch64-simd.md (@aarch64_fmmlaq<mode>): New
> > pattern.
> > (@aarch64_<insn><mode>): Use VQ_HSF_F8_FMMLA.
> > * config/aarch64/aarch64-sve-builtins-sve2.def (svmmla): Define
> > new SVE functions for F16MM and SVE_B16MM.
> > * config/aarch64/aarch64-sve2.md
> >
> > (@aarch64_sve_<sve_fp_op><SVE_FULL_HF_FMMLA:mode><SVE_FULL_HF_FMMLA:mode>):
> > New pattern.
> > * config/aarch64/aarch64.h
> > (TARGET_F16F32MM, TARGET_F16MM, TARGET_SVE_B16MM): New macros.
> > * config/aarch64/iterators.md (VQ_HSF_F16_FMMLA): New iterator.
> > (VQ_HSF_F8_FMMLA): Rename from VDQ_HSF_FMMLA.
> > (SVE_FULL_HF_FMMLA): New iterator.
> >
> > gcc/testsuite/ChangeLog:
> > * gcc.target/aarch64/advsimd-intrinsics/fmmla-compile.c: New
> > test.
> > * gcc.target/aarch64/pragma_cpp_predefs_4.c: Test new feature
> > macros.
> > * gcc.target/aarch64/sve/acle/general-c/mmla_1.c: Remove
> > obsolete test
> > * gcc.target/aarch64/sve/acle/general-c/mmla_8.c: New test.
> > * gcc.target/aarch64/sve2/acle/asm/fmmla_bf16.c: New test.
> > * gcc.target/aarch64/sve2/acle/asm/fmmla_f16.c: New test.
> > * lib/target-supports.exp ("f16mm", "f16f32mm", "sve-b16mm"):
> > Add assembly extension checks.
> > ---
> >
> > Changes from v3:
> > * Reuse cvt_f32_f16 and h_float instead of adding neon_fmmlaq
> > type lists.
> > * Rename gimple_vmmlaq to vmmlaq_impl and derive directly from
> > function_base.
> > * Use e.result_mode () instead in vmmlaq_impl::expand.
> > e.vector_mode cannot be used here since it uses SVE machine
> > mode.
> > * Split the existing SVE FMMLA pattern renaming and expansion
> > simplification into another patch. Use the common
> > two-mode aarch64_sve FMMLA interface for the new patterns.
> > * Rename the FMMLA iterators to VQ_HSF_F16_FMMLA and
> > VQ_HSF_F8_FMMLA to distinguish their source formats.
> > * Move the SVE feature checks to SVE_FULL_HF_FMMLA iterator.
> > * Add a movprfx alternative for the new SVE instructions.
> > * Rename the SVE assembly tests to fmmla_bf16.c and fmmla_f16.c,
> > and add mmla_8.c to check the missing-SVE2p2 diagnostic.
> >
> > Changes from v2:
> > * vmmlaq_f16_f16 changed to vmmlaq_f16.
> >
> > Changes from v1:
> > * works on top of the changes made to NEON intrinsics.
> > * gating of the svmmla_f16 with +sve2p2.
> >
> > gcc/config/aarch64/aarch64-c.cc | 3 +++
> > .../aarch64/aarch64-neon-builtins-base.cc | 13 +++++++++
> > .../aarch64/aarch64-neon-builtins-base.def | 11 +++++++-
> > gcc/config/aarch64/aarch64-simd.md | 18 ++++++++++---
> > .../aarch64/aarch64-sve-builtins-sve2.def | 10 +++++++
> > gcc/config/aarch64/aarch64-sve2.md | 24 +++++++++++++++++
> > gcc/config/aarch64/aarch64.h | 6 +++++
> > gcc/config/aarch64/iterators.md | 14 +++++++---
> > .../advsimd-intrinsics/fmmla-compile.c | 27 +++++++++++++++++++
> > .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 15 +++++++++++
> > .../aarch64/sve/acle/general-c/mmla_1.c | 1 -
> > .../aarch64/sve/acle/general-c/mmla_8.c | 10 +++++++
> > .../aarch64/sve2/acle/asm/fmmla_bf16.c | 27 +++++++++++++++++++
> > .../aarch64/sve2/acle/asm/fmmla_f16.c | 27 +++++++++++++++++++
> > gcc/testsuite/lib/target-supports.exp | 6 ++---
> > 15 files changed, 201 insertions(+), 11 deletions(-)
> > create mode 100644
> > gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/fmmla-compile.c
> > create mode 100644
> > gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_8.c
> > create mode 100644
> > gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_bf16.c
> > create mode 100644
> > gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_f16.c
> >
> > diff --git a/gcc/config/aarch64/aarch64-c.cc
> > b/gcc/config/aarch64/aarch64-c.cc
> > index 09b3b53e1fb1..6ed87c8dbb70 100644
> > --- a/gcc/config/aarch64/aarch64-c.cc
> > +++ b/gcc/config/aarch64/aarch64-c.cc
> > @@ -347,6 +347,9 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
> >
> > aarch64_def_or_undef (TARGET_F8F16MM, "__ARM_FEATURE_F8F16MM", pfile);
> > aarch64_def_or_undef (TARGET_F8F32MM, "__ARM_FEATURE_F8F32MM", pfile);
> > + aarch64_def_or_undef (TARGET_F16MM, "__ARM_FEATURE_F16MM", pfile);
> > + aarch64_def_or_undef (TARGET_F16F32MM, "__ARM_FEATURE_F16F32MM", pfile);
> > + aarch64_def_or_undef (TARGET_SVE_B16MM, "__ARM_FEATURE_SVE_B16MM",
> > pfile);
> > aarch64_def_or_undef (TARGET_SVE_F16F32MM, "__ARM_FEATURE_SVE_F16F32MM",
> > pfile);
> > }
> > diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.cc
> > b/gcc/config/aarch64/aarch64-neon-builtins-base.cc
> > index b00aed7c7d77..0ec34b12137d 100644
> > --- a/gcc/config/aarch64/aarch64-neon-builtins-base.cc
> > +++ b/gcc/config/aarch64/aarch64-neon-builtins-base.cc
> > @@ -764,6 +764,16 @@ struct gimple_reinterpret : public gimple_function_base
> > }
> > };
> >
> > +/* FP16 matrix-multiply accumulate (widening and non-widening). */
> > +class vmmlaq_impl : public function_base
> > +{
> > +public:
> > + rtx expand (function_expander &e) const override
> > + {
> > + return e.use_exact_insn (code_for_aarch64_fmmlaq (e.result_mode ()));
>
> Hmm, when I suggested using e.vector_mode () here, I'd assumed that the NEON
> intrinsics port had associated a NEON mode with each type suffix, and that
> would be given by e.vector_mode (). This turns out not to be the case. So
> apologies for misleading you here.
>
> I think longer term it would be good for DEF_SVE_NEON_TYPE_SUFFIX to rename
> its MODE parameter to SVE_MODE, and to add a NEON_MODE paramter. Then we can
> store the neon mode in type_suffix_info and expose, say, a neon_mode () helper
> to go alongside vector_mode () in function_instance.
>
> However, that's certainly not something that should hold up this patch, so
> don't worry about that for now.
>
Ok!
> > + }
> > +};
> > +
> > // Reinterpret
> > NEON_FUNCTION (vreinterpret, vreinterpretq, gimple_reinterpret,)
> >
> <snip>
> > diff --git
> > a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/fmmla-compile.c
> > b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/fmmla-compile.c
> > new file mode 100644
> > index 000000000000..0409f5ad1af6
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/fmmla-compile.c
>
> I'm not sure if the advsimd-intrinsics directory is the best choice for this
> test, given that:
>
> - It is shared with the arm port, which you have to work around below.
> - AIUI, it's mainly intended to be execution tests which are run at various
> optimization levels (torture tests).
>
> So I'd say this one would be better suited to the acle subdirectory, and
> we can then drop the `aarch64-*-*-* &&` conditions below.
>
Sure - I put this here because it seemed similar to another test. However,
after looking again, it seems like it's not necessary.
> > @@ -0,0 +1,27 @@
> > +/* { dg-do assemble { target { aarch64*-*-* && { aarch64_asm_f16f32mm_ok
> > && aarch64_asm_f16mm_ok } } } } */
> > +/* { dg-do compile { target { aarch64*-*-* && { ! {
> > aarch64_asm_f16f32mm_ok && aarch64_asm_f16mm_ok } } } } } */
> > +/* { dg-additional-options "-O2 -march=armv8-a+f16f32mm+f16mm -save-temps"
> > } */
> > +/* { dg-final { check-function-bodies "**" "" } } */
> > +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } } */
> > +
> > +#include <arm_neon.h>
> > +
> > +/*
> > +** test_fmmla1:
> > +** fmmla v0\.4s, v1\.8h, v2\.8h
> > +** ret
> > +*/
> > +float32x4_t test_fmmla1 (float32x4_t r, float16x8_t x, float16x8_t y)
> > +{
> > + return vmmlaq_f32_f16 (r, x, y);
> > +}
> > +
> > +/*
> > +** test_fmmla2:
> > +** fmmla v0\.8h, v1\.8h, v2\.8h
> > +** ret
> > +*/
> > +float16x8_t test_fmmla2 (float16x8_t r, float16x8_t x, float16x8_t y)
> > +{
> > + return vmmlaq_f16 (r, x, y);
> > +}
> > diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c
> > b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c
> > index 4caa01bba0f8..9ba60c2be1ec 100644
> > --- a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c
> > +++ b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c
> > @@ -430,3 +430,18 @@
> > #ifdef __ARM_FEATURE_CSSC
> > #error Foo
> > #endif
> > +
> > +#pragma GCC target "+nothing+f16mm"
> > +#ifndef __ARM_FEATURE_F16MM
> > +#error Foo
> > +#endif
> > +
> > +#pragma GCC target "+nothing+f16f32mm"
> > +#ifndef __ARM_FEATURE_F16F32MM
> > +#error Foo
> > +#endif
> > +
> > +#pragma GCC target "+nothing+sve-b16mm"
> > +#ifndef __ARM_FEATURE_SVE_B16MM
> > +#error Foo
> > +#endif
> > diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_1.c
> > b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_1.c
> > index a23c45c86b14..c616ad425c40 100644
> > --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_1.c
> > +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_1.c
> > @@ -52,7 +52,6 @@ f2 (svbool_t pg, svint8_t s8, svuint8_t u8, svuint32_t
> > u32, svint32_t s32,
> > svmmla (f64, f32, f16); /* { dg-error {'svmmla' has no form that takes
> > 'svfloat64_t' and 'svfloat32_t' arguments} } */
> > svmmla (f64, f64, f16); /* { dg-error {passing 'svfloat16_t' to argument
> > 3 of 'svmmla', but argument 2 had type 'svfloat64_t'} } */
> >
> > - svmmla (f16, f16, f16); /* { dg-error {'svmmla' has no form that takes
> > 'svfloat16_t' arguments} } */
> > svmmla (f32, f32, f32);
> > svmmla (f64, f64, f64);
> > }
> > diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_8.c
> > b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_8.c
> > new file mode 100644
> > index 000000000000..430e4378bf0e
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/mmla_8.c
>
> Is there a reason for this test to be in the general-c folder as opposed
> to the general folder (i.e. does it need to be restricted to C only)?
>
I've just moved the test (which now passes) from mmla_1.c to a new test file
and followed the other mmla_N tests.
> The patch is OK with these comments addressed. Thanks for your
> patience on this.
>
> Alex
>
Thanks for the review! Just to add, I don't have commit rights to gcc yet so
I'll send the new version again - I'd appreciate if somebody can commit this.
Ezra
> > @@ -0,0 +1,10 @@
> > +/* { dg-do compile } */
> > +/* { dg-additional-options "-march=armv8.2-a+sve" } */
> > +
> > +#include <arm_sve.h>
> > +
> > +void
> > +f1 (svfloat16_t f16)
> > +{
> > + svmmla (f16, f16, f16); /* { dg-error {ACLE function 'svmmla_f16'
> > requires ISA extension 'sve2p2'} } */
> > +}
> > diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_bf16.c
> > b/gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_bf16.c
> > new file mode 100644
> > index 000000000000..2e8a62218fad
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_bf16.c
> > @@ -0,0 +1,27 @@
> > +/* { dg-do assemble { target aarch64_asm_sve-b16mm_ok } } */
> > +/* { dg-do compile { target { ! aarch64_asm_sve-b16mm_ok } } } */
> > +/* { dg-skip-if "" { *-*-* } { "-DSTREAMING_COMPATIBLE" } { "" } } */
> > +/* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" } } */
> > +
> > +#include "test_sve_acle.h"
> > +
> > +#pragma GCC target "+sve-b16mm"
> > +
> > +/*
> > +** svmmla_bf16mm_tied:
> > +** bfmmla z0\.h, z4\.h, z5\.h
> > +** ret
> > +*/
> > +TEST_DUAL_Z (svmmla_bf16mm_tied, svbfloat16_t, svbfloat16_t,
> > + z0 = svmmla_bf16 (z0, z4, z5),
> > + z0 = svmmla (z0, z4, z5))
> > +
> > +/*
> > +** svmmla_bf16mm:
> > +** movprfx z0, z1
> > +** bfmmla z0\.h, z4\.h, z5\.h
> > +** ret
> > +*/
> > +TEST_DUAL_Z (svmmla_bf16mm, svbfloat16_t, svbfloat16_t,
> > + z0 = svmmla_bf16 (z1, z4, z5),
> > + z0 = svmmla (z1, z4, z5))
> > diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_f16.c
> > b/gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_f16.c
> > new file mode 100644
> > index 000000000000..b5adf846d227
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/fmmla_f16.c
> > @@ -0,0 +1,27 @@
> > +/* { dg-do assemble { target { aarch64_asm_sve2p2_ok &&
> > aarch64_asm_f16mm_ok } } } */
> > +/* { dg-do compile { target { ! { aarch64_asm_sve2p2_ok &&
> > aarch64_asm_f16mm_ok } } } } */
> > +/* { dg-skip-if "" { *-*-* } { "-DSTREAMING_COMPATIBLE" } { "" } } */
> > +/* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" } } */
> > +
> > +#include "test_sve_acle.h"
> > +
> > +#pragma GCC target "+sve2p2+f16mm"
> > +
> > +/*
> > +** svmmla_f16mm_tied:
> > +** fmmla z0\.h, z4\.h, z5\.h
> > +** ret
> > +*/
> > +TEST_DUAL_Z (svmmla_f16mm_tied, svfloat16_t, svfloat16_t,
> > + z0 = svmmla_f16 (z0, z4, z5),
> > + z0 = svmmla (z0, z4, z5))
> > +
> > +/*
> > +** svmmla_f16mm:
> > +** movprfx z0, z1
> > +** fmmla z0\.h, z4\.h, z5\.h
> > +** ret
> > +*/
> > +TEST_DUAL_Z (svmmla_f16mm, svfloat16_t, svfloat16_t,
> > + z0 = svmmla_f16 (z1, z4, z5),
> > + z0 = svmmla (z1, z4, z5))
> > diff --git a/gcc/testsuite/lib/target-supports.exp
> > b/gcc/testsuite/lib/target-supports.exp
> > index 3c5dfd59f6fe..c444518c448b 100644
> > --- a/gcc/testsuite/lib/target-supports.exp
> > +++ b/gcc/testsuite/lib/target-supports.exp
> > @@ -13228,9 +13228,9 @@ proc
> > check_effective_target_aarch64_gas_has_dtprel_reloc { } {
> > set exts {
> > "bf16" "cmpbr" "crc" "crypto" "dotprod" "f32mm" "f64mm" "faminmax"
> > "fp" "fp8" "fp8dot2" "fp8dot4" "fp8fma" "i8mm" "ls64" "lse" "lut"
> > - "sb" "simd" "sve-b16b16" "sve" "sve2" "sve-sm4" "sve-aes" "sve-aes2"
> > - "sve-bitperm" "sve-sha3" "f8f16mm" "f8f32mm" "sve-f16f32mm"
> > - "sme-f8f16" "sme-f8f32"
> > + "sb" "simd" "f16mm" "f16f32mm" "sve-b16b16" "sve" "sve2" "sve-sm4"
> > + "sve-aes" "sve-aes2" "sve-bitperm" "sve-sha3" "f8f16mm" "f8f32mm"
> > + "sve-f16f32mm" "sve-b16mm" "sme-f8f16" "sme-f8f32"
> > "sme-b16b16" "sme-f16f16" "sme-i16i64" "sme" "sme2" "sme2p1" "sme2p2"
> > "sme2p3"
> > "sme-tmop"
> > --
> > 2.53.0
> >