public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: liuhongt <hongtao.liu@intel.com>
To: gcc-patches@gcc.gnu.org
Cc: crazylht@gmail.com, hjl.tools@gmail.com,
	Hongyu Wang <hongyu.wang@intel.com>
Subject: [PATCH 3/7] AVX512FP16: Add expander for smin/maxhf3.
Date: Thu, 23 Sep 2021 13:46:36 +0800	[thread overview]
Message-ID: <20210923054640.1406227-4-hongtao.liu@intel.com> (raw)
In-Reply-To: <20210923054640.1406227-1-hongtao.liu@intel.com>

From: Hongyu Wang <hongyu.wang@intel.com>

gcc/ChangeLog:

	* config/i386/i386.md (<code>hf3): New expander.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-builtin-minmax-1.c: New test.
---
 gcc/config/i386/i386.md                       | 11 ++++++
 .../i386/avx512fp16-builtin-minmax-1.c        | 35 +++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/avx512fp16-builtin-minmax-1.c

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 4b13a59be82..a087e557d7f 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -19946,6 +19946,17 @@ (define_insn "<code><mode>3"
    (set_attr "type" "sseadd")
    (set_attr "mode" "<MODE>")])
 
+(define_insn "<code>hf3"
+  [(set (match_operand:HF 0 "register_operand" "=v")
+	(smaxmin:HF
+	  (match_operand:HF 1 "nonimmediate_operand" "%v")
+	  (match_operand:HF 2 "nonimmediate_operand" "vm")))]
+  "TARGET_AVX512FP16"
+  "v<maxmin_float>sh\t{%2, %1, %0|%0, %1, %2}"
+  [(set_attr "prefix" "evex")
+   (set_attr "type" "sseadd")
+   (set_attr "mode" "HF")])
+
 ;; These versions of the min/max patterns implement exactly the operations
 ;;   min = (op1 < op2 ? op1 : op2)
 ;;   max = (!(op1 < op2) ? op1 : op2)
diff --git a/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-minmax-1.c b/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-minmax-1.c
new file mode 100644
index 00000000000..90080e44216
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-minmax-1.c
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -mavx512fp16 -mprefer-vector-width=512" } */
+
+_Float16
+minf1 (_Float16 a, _Float16 b)
+{
+  return __builtin_fminf16 (a, b);
+}
+
+void
+minf2 (_Float16* __restrict psrc1, _Float16* __restrict psrc2,
+       _Float16* __restrict pdst)
+{
+  for (int i = 0; i != 32; i++)
+    pdst[i] = __builtin_fminf16 (psrc1[i], psrc2[i]);
+}
+
+_Float16
+maxf1 (_Float16 a, _Float16 b)
+{
+  return __builtin_fmaxf16 (a, b);
+}
+
+void
+maxf2 (_Float16* __restrict psrc1, _Float16* __restrict psrc2,
+       _Float16* __restrict pdst)
+{
+  for (int i = 0; i != 32; i++)
+    pdst[i] = __builtin_fmaxf16 (psrc1[i], psrc2[i]);
+}
+
+/* { dg-final { scan-assembler-times "vmaxsh\[^\n\r\]*xmm\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "vmaxph\[^\n\r\]*zmm\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "vminsh\[^\n\r\]*xmm\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "vminph\[^\n\r\]*zmm\[0-9\]" 1 } } */
-- 
2.27.0


  parent reply	other threads:[~2021-09-23  5:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  5:46 [PATCH 0/7] AVX512FP16: Support bunch of expanders for HFmode and vector HFmodes liuhongt
2021-09-23  5:46 ` [PATCH 1/7] AVX512FP16: Add expander for rint/nearbyinthf2 liuhongt
2021-09-23  5:46 ` [PATCH 2/7] AVX512FP16: Add expander for fmahf4 liuhongt
2021-09-23  5:46 ` liuhongt [this message]
2021-09-23  5:46 ` [PATCH 4/7] AVX512FP16: Add fix(uns)?_truncmn2 for HF scalar and vector modes liuhongt
2021-09-23  5:46 ` [PATCH 5/7] AVX512FP16: Add float(uns)?mn2 expander liuhongt
2021-09-23  5:46 ` [PATCH 6/7] AVX512FP16: add truncmn2/extendmn2 expanders liuhongt
2021-09-23  5:46 ` [PATCH 7/7] AVX512FP16: Enable vec_cmpmn/vcondmn expanders for HF modes liuhongt

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=20210923054640.1406227-4-hongtao.liu@intel.com \
    --to=hongtao.liu@intel.com \
    --cc=crazylht@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=hongyu.wang@intel.com \
    /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: link
Be 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).