public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: hongtao Liu <liuhongt@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4984] [Gimple] Simplify (trunc)fma ((extend)a, (extend)b, (extend)c) to IFN_FMA (a, b, c). Date: Mon, 8 Nov 2021 01:31:17 +0000 (GMT) [thread overview] Message-ID: <20211108013117.EA737385842D@sourceware.org> (raw) https://gcc.gnu.org/g:2ad1e8081f4797a99a96b513ffe14c7305e9b3d8 commit r12-4984-g2ad1e8081f4797a99a96b513ffe14c7305e9b3d8 Author: liuhongt <hongtao.liu@intel.com> Date: Mon Nov 8 09:19:29 2021 +0800 [Gimple] Simplify (trunc)fma ((extend)a, (extend)b, (extend)c) to IFN_FMA (a,b, c). a, b, c are same type as truncation type and has less precision than extend type, the optimization is guarded under flag_unsafe_math_optimizations. gcc/ChangeLog: PR target/102464 * match.pd: Simplify (trunc)fma ((extend)a, (extend)b, (extend)c) to IFN_FMA (a, b, c) under flag_unsafe_math_optimizations. gcc/testsuite/ChangeLog: * gcc.target/i386/pr102464-fma.c: New test. Diff: --- gcc/match.pd | 15 +++++++++++++ gcc/testsuite/gcc.target/i386/pr102464-fma.c | 32 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/gcc/match.pd b/gcc/match.pd index 917833dd14b..869b26d16a0 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -6217,6 +6217,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) type, OPTIMIZE_FOR_BOTH)) (IFN_COPYSIGN @0 @1)))) +(for froms (BUILT_IN_FMAF BUILT_IN_FMA BUILT_IN_FMAL) + tos (IFN_FMA IFN_FMA IFN_FMA) + (simplify + (convert (froms (convert@3 @0) (convert @1) (convert @2))) + (if (flag_unsafe_math_optimizations + && optimize + && FLOAT_TYPE_P (type) + && FLOAT_TYPE_P (TREE_TYPE (@3)) + && types_match (type, TREE_TYPE (@0)) + && types_match (type, TREE_TYPE (@1)) + && types_match (type, TREE_TYPE (@2)) + && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@3)) + && direct_internal_fn_supported_p (as_internal_fn (tos), + type, OPTIMIZE_FOR_BOTH)) + (tos @0 @1 @2)))) #endif (for froms (XFLOORL XCEILL XROUNDL XRINTL) diff --git a/gcc/testsuite/gcc.target/i386/pr102464-fma.c b/gcc/testsuite/gcc.target/i386/pr102464-fma.c new file mode 100644 index 00000000000..9c70d93d980 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr102464-fma.c @@ -0,0 +1,32 @@ +/* PR target/102464. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512fp16 -mavx512vl -ffast-math -ftree-vectorize -mtune=generic -mfpmath=sse" } */ +/* { dg-final { scan-assembler-times "vfmadd...ph" 3 } } */ +/* { dg-final { scan-assembler-times "vfmadd...sh" 3 } } */ +/* { dg-final { scan-assembler-times "vfmadd...ps" 2 } } */ +/* { dg-final { scan-assembler-times "vfmadd...ss" 2 } } */ +/* { dg-final { scan-assembler-times "vfmadd...pd" 1 } } */ +/* { dg-final { scan-assembler-times "vfmadd...sd" 1 } } */ + +#include<math.h> +#define FOO(TYPE,SUFFIX) \ + void \ + foo_vect_##TYPE##SUFFIX (TYPE* __restrict a, TYPE* b, TYPE* c, TYPE* d) \ + { \ + for (int i = 0; i != 8; i++) \ + a[i] = fma##SUFFIX (b[i], c[i], d[i]); \ + } \ + TYPE \ + foo_##TYPE##SUFFIX (TYPE b, TYPE c, TYPE d) \ + { \ + return fma##l (b, c, d); \ + } + +FOO (_Float16, f); +FOO (_Float16,); +FOO (_Float16, l); + +FOO (float,); +FOO (float, l); + +FOO (double, l);
reply other threads:[~2021-11-08 1:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211108013117.EA737385842D@sourceware.org \ --to=liuhongt@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).