From: Christophe Lyon <[email protected]>

Implement vpnot using the new MVE builtins framework.

gcc/ChangeLog:

        * config/arm/arm-mve-builtins-base.cc (class mve_function_vpnot): New.
        (vpnot): New.
        * config/arm/arm-mve-builtins-base.def (vpnot): New.
        * config/arm/arm-mve-builtins-base.h (vpnot): New.
        * config/arm/arm-mve-builtins-shapes.cc (struct vpnot): New.
        * config/arm/arm-mve-builtins-shapes.h (vpnot): New.
        * config/arm/arm_mve.h (vpnot): Delete.
        (__arm_vpnot): Delete.
---
 gcc/config/arm/arm-mve-builtins-base.cc   | 19 +++++++++++++++++++
 gcc/config/arm/arm-mve-builtins-base.def  |  1 +
 gcc/config/arm/arm-mve-builtins-base.h    |  1 +
 gcc/config/arm/arm-mve-builtins-shapes.cc | 15 +++++++++++++++
 gcc/config/arm/arm-mve-builtins-shapes.h  |  1 +
 gcc/config/arm/arm_mve.h                  |  8 --------
 6 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/gcc/config/arm/arm-mve-builtins-base.cc b/gcc/config/arm/arm-mve-builtins-base.cc
index fd0be2cbcd8..e5016f7fb23 100644
--- a/gcc/config/arm/arm-mve-builtins-base.cc
+++ b/gcc/config/arm/arm-mve-builtins-base.cc
@@ -1167,6 +1167,24 @@ public:
   }
 };
 
+/* Map the function directly to mve_vpnotv16bi, and convert the result into
+   HImode like we do for vcmp.  */
+class mve_function_vpnot : public function_base
+{
+public:
+  CONSTEXPR mve_function_vpnot (void)
+  {}
+
+  rtx
+  expand (function_expander &e) const override
+  {
+    rtx target = e.use_unpred_insn (CODE_FOR_mve_vpnotv16bi);
+    rtx HItarget = gen_reg_rtx (HImode);
+    emit_move_insn (HItarget, gen_lowpart (HImode, target));
+    return HItarget;
+  }
+};
+
 } /* end anonymous namespace */
 
 namespace arm_mve {
@@ -1453,6 +1471,7 @@ FUNCTION (vmulltq_poly, unspec_mve_function_exact_insn_vmull_poly, (VMULLTQ_POLY
 FUNCTION_WITH_RTX_M_N (vmulq, MULT, VMULQ)
 FUNCTION_WITH_RTX_M_N_NO_F (vmvnq, NOT, VMVNQ)
 FUNCTION (vnegq, unspec_based_mve_function_exact_insn, (NEG, NEG, NEG, -1, -1, -1, VNEGQ_M_S, -1, VNEGQ_M_F, -1, -1, -1))
+FUNCTION (vpnot, mve_function_vpnot, )
 FUNCTION_WITHOUT_M_N (vpselq, VPSELQ)
 FUNCTION (vornq, unspec_based_mve_function_exact_insn_vorn, (-1, -1, VORNQ_M_S, VORNQ_M_U, VORNQ_M_F, -1, -1))
 FUNCTION_WITH_RTX_M_N_NO_N_F (vorrq, IOR, VORRQ)
diff --git a/gcc/config/arm/arm-mve-builtins-base.def b/gcc/config/arm/arm-mve-builtins-base.def
index 0400c3c540e..5c2860dc720 100644
--- a/gcc/config/arm/arm-mve-builtins-base.def
+++ b/gcc/config/arm/arm-mve-builtins-base.def
@@ -113,6 +113,7 @@ DEF_MVE_FUNCTION (vmvnq, mvn, all_integer, mx_or_none)
 DEF_MVE_FUNCTION (vnegq, unary, all_signed, mx_or_none)
 DEF_MVE_FUNCTION (vornq, binary_orrq, all_integer, mx_or_none)
 DEF_MVE_FUNCTION (vorrq, binary_orrq, all_integer, mx_or_none)
+DEF_MVE_FUNCTION (vpnot, vpnot, none, none)
 DEF_MVE_FUNCTION (vpselq, vpsel, all_integer_with_64, none)
 DEF_MVE_FUNCTION (vqabsq, unary, all_signed, m_or_none)
 DEF_MVE_FUNCTION (vqaddq, binary_opt_n, all_integer, m_or_none)
diff --git a/gcc/config/arm/arm-mve-builtins-base.h b/gcc/config/arm/arm-mve-builtins-base.h
index 6ff3195e888..2b6b6b5a9ef 100644
--- a/gcc/config/arm/arm-mve-builtins-base.h
+++ b/gcc/config/arm/arm-mve-builtins-base.h
@@ -144,6 +144,7 @@ extern const function_base *const vmvnq;
 extern const function_base *const vnegq;
 extern const function_base *const vornq;
 extern const function_base *const vorrq;
+extern const function_base *const vpnot;
 extern const function_base *const vpselq;
 extern const function_base *const vqabsq;
 extern const function_base *const vqaddq;
diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc b/gcc/config/arm/arm-mve-builtins-shapes.cc
index aeb14530a08..b324c2847db 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.cc
+++ b/gcc/config/arm/arm-mve-builtins-shapes.cc
@@ -2710,6 +2710,21 @@ struct vidwdup_def : public overloaded_base<0>
 };
 SHAPE (vidwdup)
 
+/* mve_pred16_t foo_t0(mve_pred16_t)
+
+   Example: vpnot.
+   mve_pred16_t [__arm_]vpnot(mve_pred16_t a)  */
+struct vpnot_def : public nonoverloaded_base
+{
+  void
+  build (function_builder &b, const function_group_info &group,
+	 bool preserve_user_namespace) const override
+  {
+    build_all (b, "p,p", group, MODE_none, preserve_user_namespace);
+  }
+};
+SHAPE (vpnot)
+
 /* <T0>_t vfoo[_t0](<T0>_t, <T0>_t, mve_pred16_t)
 
    i.e. a version of the standard ternary shape in which
diff --git a/gcc/config/arm/arm-mve-builtins-shapes.h b/gcc/config/arm/arm-mve-builtins-shapes.h
index 6b839c577c6..7614c92d1cd 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.h
+++ b/gcc/config/arm/arm-mve-builtins-shapes.h
@@ -90,6 +90,7 @@ namespace arm_mve
     extern const function_shape *const vcvtx;
     extern const function_shape *const viddup;
     extern const function_shape *const vidwdup;
+    extern const function_shape *const vpnot;
     extern const function_shape *const vpsel;
     extern const function_shape *const vshlc;
 
diff --git a/gcc/config/arm/arm_mve.h b/gcc/config/arm/arm_mve.h
index ee18a4714fb..64b22759a99 100644
--- a/gcc/config/arm/arm_mve.h
+++ b/gcc/config/arm/arm_mve.h
@@ -50,7 +50,6 @@
 #define vgetq_lane(__a, __idx) __arm_vgetq_lane(__a, __idx)
 
 
-#define vpnot(__a) __arm_vpnot(__a)
 #define vuninitializedq_u8(void) __arm_vuninitializedq_u8(void)
 #define vuninitializedq_u16(void) __arm_vuninitializedq_u16(void)
 #define vuninitializedq_u32(void) __arm_vuninitializedq_u32(void)
@@ -111,13 +110,6 @@
   __builtin_arm_lane_check (__ARM_NUM_LANES(__vec),     \
 			    __ARM_LANEQ(__vec, __idx))
 
-__extension__ extern __inline mve_pred16_t
-__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
-__arm_vpnot (mve_pred16_t __a)
-{
-  return __builtin_mve_vpnotv16bi (__a);
-}
-
 __extension__ extern __inline int16x8_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vsetq_lane_s16 (int16_t __a, int16x8_t __b, const int __idx)

Reply via email to