public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] aarch64: Add fix_truncv4sfv4hi2 pattern [PR113882]
@ 2024-06-04  1:09 Pengxuan Zheng
  2024-06-06 12:29 ` Richard Sandiford
  0 siblings, 1 reply; 5+ messages in thread
From: Pengxuan Zheng @ 2024-06-04  1:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: Pengxuan Zheng

This patch adds the fix_truncv4sfv4hi2 (V4SF->V4HI) pattern which is implemented
using fix_truncv4sfv4si2 (V4SF->V4SI) and then truncv4siv4hi2 (V4SI->V4HI).

	PR target/113882

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (fix_truncv4sfv4hi2): New pattern.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/fix_trunc2.c: New test.

Signed-off-by: Pengxuan Zheng <quic_pzheng@quicinc.com>
---
 gcc/config/aarch64/aarch64-simd.md            | 13 +++++++++++++
 gcc/testsuite/gcc.target/aarch64/fix_trunc2.c | 14 ++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/fix_trunc2.c

diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 868f4486218..096f7b56a27 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -3032,6 +3032,19 @@ (define_expand "<fix_trunc_optab><VHSDF:mode><fcvt_target>2"
   "TARGET_SIMD"
   {})
 
+
+(define_expand "fix_truncv4sfv4hi2"
+  [(match_operand:V4HI 0 "register_operand")
+   (match_operand:V4SF 1 "register_operand")]
+  "TARGET_SIMD"
+  {
+    rtx tmp = gen_reg_rtx (V4SImode);
+    emit_insn (gen_fix_truncv4sfv4si2 (tmp, operands[1]));
+    emit_insn (gen_truncv4siv4hi2 (operands[0], tmp));
+    DONE;
+  }
+)
+
 (define_expand "ftrunc<VHSDF:mode>2"
   [(set (match_operand:VHSDF 0 "register_operand")
 	(unspec:VHSDF [(match_operand:VHSDF 1 "register_operand")]
diff --git a/gcc/testsuite/gcc.target/aarch64/fix_trunc2.c b/gcc/testsuite/gcc.target/aarch64/fix_trunc2.c
new file mode 100644
index 00000000000..57cc00913a3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fix_trunc2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+f (short *__restrict a, float *__restrict b)
+{
+  a[0] = b[0];
+  a[1] = b[1];
+  a[2] = b[2];
+  a[3] = b[3];
+}
+
+/* { dg-final { scan-assembler-times {fcvtzs\tv[0-9]+.4s, v[0-9]+.4s} 1 } } */
+/* { dg-final { scan-assembler-times {xtn\tv[0-9]+.4h, v[0-9]+.4s} 1 } } */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-18  5:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04  1:09 [PATCH] aarch64: Add fix_truncv4sfv4hi2 pattern [PR113882] Pengxuan Zheng
2024-06-06 12:29 ` Richard Sandiford
2024-06-06 13:22   ` Richard Biener
2024-06-18  0:05   ` Pengxuan Zheng (QUIC)
2024-06-18  5:55     ` Richard Biener

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).