[PATCH v2] aarch64: Add support for AdvSIMD faminmax
saurabh.jha@arm.com
saurabh.jha@arm.com
Thu Aug 1 13:40:04 GMT 2024
The AArch64 FEAT_FAMINMAX extension is optional from Armv9.2-a and
mandatory from Armv9.5-a. It introduces instructions for computing the
floating point absolute maximum and minimum of the two vectors element-wise.
This patch does three things:
1. Introduces AdvSIMD faminmax intrinsics.
2. Adds code generation support for famax and famin in terms of the
existing operators.
3. Move report_missing_extension and reported_missing_extension_p to
make it more usable.
The intrinsics of this extension are implemented as the following
builtin functions:
* vamax_f16
* vamaxq_f16
* vamax_f32
* vamaxq_f32
* vamaxq_f64
* vamin_f16
* vaminq_f16
* vamin_f32
* vaminq_f32
* vaminq_f64
For code generation, famax/famin is equivalent to first taking fabs of
the operands and then taking fmax/fmin of the results of fabs.
famax/famin (a, b) = fmax/fmin (fabs (a), fabs (b))
This is correct because NaN/Inf handling of famax/famin and fmax/fmin
are same. We cannot use fmaxnm/fminnm here as Nan/Inf are handled
differently in them.
We moved the definition of `report_missing_extension` from
gcc/config/aarch64/aarch64-sve-builtins.cc to
gcc/config/aarch64/aarch64-builtins.cc and its declaration to
gcc/config/aarch64/aarch64-builtins.h. We also moved the declaration
of `reported_missing_extension_p` from
gcc/config/aarch64/aarch64-sve-builtins.cc
to gcc/config/aarch64/aarch64-builtins.cc, closer to the definition of
`report_missing_extension`. In the exsiting code structure, this leads
to `report_missing_extension` being usable from both normal builtins
and sve builtins.
gcc/ChangeLog:
* config/aarch64/aarch64-builtins.cc
(enum aarch64_builtins): New enum values for faminmax builtins.
(aarch64_init_faminmax_builtins): New function to declare new builtins.
(handle_arm_neon_h): Modify to call aarch64_init_faminmax_builtins.
(aarch64_general_check_builtin_call): Modify to check whether +faminmax flag is being used and printing error message if not being used.
(aarch64_expand_builtin_faminmax): New function to emit instructions of this extension.
(aarch64_general_expand_builtin): Modify to call aarch64_expand_builtin_faminmax.
(report_missing_extension): Move from config/aarch64/aarch64-sve-builtins.cc.
* config/aarch64/aarch64-builtins.h
(report_missing_extension): Declaration for this function so
that it can be used wherever this header is included.
(reported_missing_extension_p): Move from
config/aarch64/aarch64-sve-builtins.cc
* config/aarch64/aarch64-option-extensions.def
(AARCH64_OPT_EXTENSION): Introduce new flag for this extension.
* config/aarch64/aarch64-simd.md
(aarch64_<faminmax><mode>): Introduce instruction pattern for this extension.
* config/aarch64/aarch64-sve-builtins.cc
(reported_missing_extension_p): Move to config/aarch64/aarch64-builtins.cc
(report_missing_extension): Move to
config/aarch64/aarch64-builtins.cc.
* config/aarch64/aarch64.h
(TARGET_FAMINMAX): Introduce new flag for this extension.
* config/aarch64/iterators.md: Introduce new iterators for this extension.
* config/arm/types.md: Introduce neon_fp_aminmax<q> attributes.
* doc/invoke.texi: Document extension in AArch64 Options.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/simd/faminmax-builtins-no-flag.c: New test.
* gcc.target/aarch64/simd/faminmax-builtins.c: New test.
* gcc.target/aarch64/simd/faminmax-codegen-no-flag.c: New test.
* gcc.target/aarch64/simd/faminmax-codegen.c: New test.
---
Hi,
Regression tested for aarch64-none-linux-gnu and found no regressions.
This is a respin of
https://gcc.gnu.org/pipermail/gcc-patches/2024-August/658968.html
as the previous version failed patchwork CI due to not being able to
apply.
Ok for master? I don't have commit access so can someone please commit
on my behalf?
Regards,
Saurabh
---
gcc/config/aarch64/aarch64-builtins.cc | 173 +++++++++++++++++-
gcc/config/aarch64/aarch64-builtins.h | 5 +-
.../aarch64/aarch64-option-extensions.def | 2 +
gcc/config/aarch64/aarch64-simd.md | 12 ++
gcc/config/aarch64/aarch64-sve-builtins.cc | 22 ---
gcc/config/aarch64/aarch64.h | 4 +
gcc/config/aarch64/iterators.md | 8 +
gcc/config/arm/types.md | 6 +
gcc/doc/invoke.texi | 2 +
.../aarch64/simd/faminmax-builtins-no-flag.c | 10 +
.../aarch64/simd/faminmax-builtins.c | 75 ++++++++
.../aarch64/simd/faminmax-codegen-no-flag.c | 54 ++++++
.../aarch64/simd/faminmax-codegen.c | 104 +++++++++++
13 files changed, 445 insertions(+), 32 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/faminmax-builtins-no-flag.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/faminmax-builtins.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/faminmax-codegen-no-flag.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/faminmax-codegen.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-aarch64-Add-support-for-AdvSIMD-faminmax.patch
Type: text/x-patch
Size: 23570 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20240801/bce36ecd/attachment-0001.bin>
More information about the Gcc-patches
mailing list