]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Use VNx16BI for svunpklo/hi_b
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 4 Aug 2025 10:45:30 +0000 (11:45 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Mon, 4 Aug 2025 10:45:30 +0000 (11:45 +0100)
This patch continues the work of making ACLE intrinsics use VNx16BI
for svbool_t results.  It deals with the svunpk* intrinsics.

gcc/
* config/aarch64/aarch64-sve.md (@aarch64_sve_punpk<perm_hilo>_acle)
(*aarch64_sve_punpk<perm_hilo>_acle): New patterns.
* config/aarch64/aarch64-sve-builtins-base.cc
(svunpk_impl::expand): Use them for boolean svunpk*.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/unpkhi_1.c: New test.
* gcc.target/aarch64/sve/acle/general/unpklo_1.c: Likewise.

gcc/config/aarch64/aarch64-sve-builtins-base.cc
gcc/config/aarch64/aarch64-sve.md
gcc/testsuite/gcc.target/aarch64/sve/acle/general/unpkhi_1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/acle/general/unpklo_1.c [new file with mode: 0644]

index 0d871a10898f4468b90cfecc7b5fbbd8de407d53..d484bb28afafb34fb9dbe6da4032cb3d068719e6 100644 (file)
@@ -3252,7 +3252,7 @@ public:
     unsigned int unpacks = m_high_p ? UNSPEC_UNPACKSHI : UNSPEC_UNPACKSLO;
     insn_code icode;
     if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL)
-      icode = code_for_aarch64_sve_punpk (unpacku, mode);
+      icode = code_for_aarch64_sve_punpk_acle (unpacku);
     else
       {
        int unspec = e.type_suffix (0).unsigned_p ? unpacku : unpacks;
index 2037dded0da58c927a690667b20779cf6b6d66b6..a3f9b9aa92d57afca0ce3c7a0dbe74862025e0ca 100644 (file)
   "punpk<perm_hilo>\t%0.h, %1.b"
 )
 
+(define_expand "@aarch64_sve_punpk<perm_hilo>_acle"
+  [(set (match_operand:VNx16BI 0 "register_operand")
+       (and:VNx16BI
+         (subreg:VNx16BI
+           (unspec:VNx8BI
+             [(match_operand:VNx16BI 1 "register_operand")]
+             UNPACK_UNSIGNED)
+           0)
+         (match_dup 2)))]
+  "TARGET_SVE"
+  {
+    operands[2] = aarch64_ptrue_all (2);
+  }
+)
+
+(define_insn "*aarch64_sve_punpk<perm_hilo>_acle"
+  [(set (match_operand:VNx16BI 0 "register_operand" "=Upa")
+       (and:VNx16BI
+         (subreg:VNx16BI
+           (unspec:VNx8BI
+             [(match_operand:VNx16BI 1 "register_operand" "Upa")]
+             UNPACK_UNSIGNED)
+           0)
+         (match_operand:VNx8BI 2 "aarch64_ptrue_all_operand")))]
+  "TARGET_SVE"
+  "punpk<perm_hilo>\t%0.h, %1.b"
+)
+
 ;; =========================================================================
 ;; == Vector partitioning
 ;; =========================================================================
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/unpkhi_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/unpkhi_1.c
new file mode 100644 (file)
index 0000000..9c7b4bc
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <arm_sve.h>
+
+svbool_t
+test1 (svbool_t p)
+{
+  return svand_z (svptrue_b8 (), svunpkhi (p), svptrue_b16 ());
+}
+
+svbool_t
+test2 (svbool_t p)
+{
+  return svand_z (svptrue_b16 (), svunpkhi (p), svptrue_b8 ());
+}
+
+svbool_t
+test3 (svbool_t p)
+{
+  return svand_z (svptrue_b16 (), svunpkhi (p), svptrue_b16 ());
+}
+
+/* { dg-final { scan-assembler-not {\tand\t} } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/unpklo_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/unpklo_1.c
new file mode 100644 (file)
index 0000000..f072a2f
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <arm_sve.h>
+
+svbool_t
+test1 (svbool_t p)
+{
+  return svand_z (svptrue_b8 (), svunpklo (p), svptrue_b16 ());
+}
+
+svbool_t
+test2 (svbool_t p)
+{
+  return svand_z (svptrue_b16 (), svunpklo (p), svptrue_b8 ());
+}
+
+svbool_t
+test3 (svbool_t p)
+{
+  return svand_z (svptrue_b16 (), svunpklo (p), svptrue_b16 ());
+}
+
+/* { dg-final { scan-assembler-not {\tand\t} } } */