RE: [PATCH 6/6] arm: [MVE intrinsics] rework vldq1 vst1q

2023-11-16 Thread Kyrylo Tkachov



> -Original Message-
> From: Christophe Lyon 
> Sent: Thursday, November 16, 2023 3:26 PM
> To: gcc-patches@gcc.gnu.org; Richard Sandiford
> ; Richard Earnshaw
> ; Kyrylo Tkachov 
> Cc: Christophe Lyon 
> Subject: [PATCH 6/6] arm: [MVE intrinsics] rework vldq1 vst1q
> 
> Implement vld1q, vst1q using the new MVE builtins framework.

Ok. Nice to see more MVE intrinsics getting the good treatment.
Thanks,
Kyrill

> 
> 2023-11-16  Christophe Lyon  
> 
>   gcc/
>   * config/arm/arm-mve-builtins-base.cc (vld1_impl, vld1q)
>   (vst1_impl, vst1q): New.
>   * config/arm/arm-mve-builtins-base.def (vld1q, vst1q): New.
>   * config/arm/arm-mve-builtins-base.h (vld1q, vst1q): New.
>   * config/arm/arm_mve.h
>   (vld1q): Delete.
>   (vst1q): Delete.
>   (vld1q_s8): Delete.
>   (vld1q_s32): Delete.
>   (vld1q_s16): Delete.
>   (vld1q_u8): Delete.
>   (vld1q_u32): Delete.
>   (vld1q_u16): Delete.
>   (vld1q_f32): Delete.
>   (vld1q_f16): Delete.
>   (vst1q_f32): Delete.
>   (vst1q_f16): Delete.
>   (vst1q_s8): Delete.
>   (vst1q_s32): Delete.
>   (vst1q_s16): Delete.
>   (vst1q_u8): Delete.
>   (vst1q_u32): Delete.
>   (vst1q_u16): Delete.
>   (__arm_vld1q_s8): Delete.
>   (__arm_vld1q_s32): Delete.
>   (__arm_vld1q_s16): Delete.
>   (__arm_vld1q_u8): Delete.
>   (__arm_vld1q_u32): Delete.
>   (__arm_vld1q_u16): Delete.
>   (__arm_vst1q_s8): Delete.
>   (__arm_vst1q_s32): Delete.
>   (__arm_vst1q_s16): Delete.
>   (__arm_vst1q_u8): Delete.
>   (__arm_vst1q_u32): Delete.
>   (__arm_vst1q_u16): Delete.
>   (__arm_vld1q_f32): Delete.
>   (__arm_vld1q_f16): Delete.
>   (__arm_vst1q_f32): Delete.
>   (__arm_vst1q_f16): Delete.
>   (__arm_vld1q): Delete.
>   (__arm_vst1q): Delete.
>   * config/arm/mve.md (mve_vld1q_f): Rename into ...
>   (@mve_vld1q_f): ... this.
>   (mve_vld1q_): Rename into ...
>   (@mve_vld1q_) ... this.
>   (mve_vst1q_f): Rename into ...
>   (@mve_vst1q_f): ... this.
>   (mve_vst1q_): Rename into ...
>   (@mve_vst1q_) ... this.
> ---
>  gcc/config/arm/arm-mve-builtins-base.cc  |  58 +
>  gcc/config/arm/arm-mve-builtins-base.def |   4 +
>  gcc/config/arm/arm-mve-builtins-base.h   |   4 +-
>  gcc/config/arm/arm_mve.h | 282 ---
>  gcc/config/arm/mve.md|   8 +-
>  5 files changed, 69 insertions(+), 287 deletions(-)
> 
> diff --git a/gcc/config/arm/arm-mve-builtins-base.cc b/gcc/config/arm/arm-
> mve-builtins-base.cc
> index 5478cac8aeb..cfe1b954a29 100644
> --- a/gcc/config/arm/arm-mve-builtins-base.cc
> +++ b/gcc/config/arm/arm-mve-builtins-base.cc
> @@ -83,6 +83,62 @@ class vuninitializedq_impl : public
> quiet
>}
>  };
> 
> +class vld1_impl : public full_width_access
> +{
> +public:
> +  unsigned int
> +  call_properties (const function_instance &) const override
> +  {
> +return CP_READ_MEMORY;
> +  }
> +
> +  rtx
> +  expand (function_expander ) const override
> +  {
> +insn_code icode;
> +if (e.type_suffix (0).float_p)
> +  icode = code_for_mve_vld1q_f(e.vector_mode (0));
> +else
> +  {
> + if (e.type_suffix (0).unsigned_p)
> +   icode = code_for_mve_vld1q(VLD1Q_U,
> +  e.vector_mode (0));
> + else
> +   icode = code_for_mve_vld1q(VLD1Q_S,
> +  e.vector_mode (0));
> +  }
> +return e.use_contiguous_load_insn (icode);
> +  }
> +};
> +
> +class vst1_impl : public full_width_access
> +{
> +public:
> +  unsigned int
> +  call_properties (const function_instance &) const override
> +  {
> +return CP_WRITE_MEMORY;
> +  }
> +
> +  rtx
> +  expand (function_expander ) const override
> +  {
> +insn_code icode;
> +if (e.type_suffix (0).float_p)
> +  icode = code_for_mve_vst1q_f(e.vector_mode (0));
> +else
> +  {
> + if (e.type_suffix (0).unsigned_p)
> +   icode = code_for_mve_vst1q(VST1Q_U,
> +  e.vector_mode (0));
> + else
> +   icode = code_for_mve_vst1q(VST1Q_S,
> +  e.vector_mode (0));
> +  }
> +return e.use_contiguous_store_insn (icode);
> +  }
> +};
> +
>  } /* end anonymous namespace */
> 
>  namespace arm_mve {
> @@ -290,6 +346,7 @@ FUNCTION (vfmasq,
> unspec_mve_function_exact_insn, (-1, -1, -1, -1, -1, VFMASQ_N_
>  FUNCTION (vfmsq, unspec_mve_function_exact_insn, (-1, -1, V

[PATCH 6/6] arm: [MVE intrinsics] rework vldq1 vst1q

2023-11-16 Thread Christophe Lyon
Implement vld1q, vst1q using the new MVE builtins framework.

2023-11-16  Christophe Lyon  

gcc/
* config/arm/arm-mve-builtins-base.cc (vld1_impl, vld1q)
(vst1_impl, vst1q): New.
* config/arm/arm-mve-builtins-base.def (vld1q, vst1q): New.
* config/arm/arm-mve-builtins-base.h (vld1q, vst1q): New.
* config/arm/arm_mve.h
(vld1q): Delete.
(vst1q): Delete.
(vld1q_s8): Delete.
(vld1q_s32): Delete.
(vld1q_s16): Delete.
(vld1q_u8): Delete.
(vld1q_u32): Delete.
(vld1q_u16): Delete.
(vld1q_f32): Delete.
(vld1q_f16): Delete.
(vst1q_f32): Delete.
(vst1q_f16): Delete.
(vst1q_s8): Delete.
(vst1q_s32): Delete.
(vst1q_s16): Delete.
(vst1q_u8): Delete.
(vst1q_u32): Delete.
(vst1q_u16): Delete.
(__arm_vld1q_s8): Delete.
(__arm_vld1q_s32): Delete.
(__arm_vld1q_s16): Delete.
(__arm_vld1q_u8): Delete.
(__arm_vld1q_u32): Delete.
(__arm_vld1q_u16): Delete.
(__arm_vst1q_s8): Delete.
(__arm_vst1q_s32): Delete.
(__arm_vst1q_s16): Delete.
(__arm_vst1q_u8): Delete.
(__arm_vst1q_u32): Delete.
(__arm_vst1q_u16): Delete.
(__arm_vld1q_f32): Delete.
(__arm_vld1q_f16): Delete.
(__arm_vst1q_f32): Delete.
(__arm_vst1q_f16): Delete.
(__arm_vld1q): Delete.
(__arm_vst1q): Delete.
* config/arm/mve.md (mve_vld1q_f): Rename into ...
(@mve_vld1q_f): ... this.
(mve_vld1q_): Rename into ...
(@mve_vld1q_) ... this.
(mve_vst1q_f): Rename into ...
(@mve_vst1q_f): ... this.
(mve_vst1q_): Rename into ...
(@mve_vst1q_) ... this.
---
 gcc/config/arm/arm-mve-builtins-base.cc  |  58 +
 gcc/config/arm/arm-mve-builtins-base.def |   4 +
 gcc/config/arm/arm-mve-builtins-base.h   |   4 +-
 gcc/config/arm/arm_mve.h | 282 ---
 gcc/config/arm/mve.md|   8 +-
 5 files changed, 69 insertions(+), 287 deletions(-)

diff --git a/gcc/config/arm/arm-mve-builtins-base.cc 
b/gcc/config/arm/arm-mve-builtins-base.cc
index 5478cac8aeb..cfe1b954a29 100644
--- a/gcc/config/arm/arm-mve-builtins-base.cc
+++ b/gcc/config/arm/arm-mve-builtins-base.cc
@@ -83,6 +83,62 @@ class vuninitializedq_impl : public quiet
   }
 };
 
+class vld1_impl : public full_width_access
+{
+public:
+  unsigned int
+  call_properties (const function_instance &) const override
+  {
+return CP_READ_MEMORY;
+  }
+
+  rtx
+  expand (function_expander ) const override
+  {
+insn_code icode;
+if (e.type_suffix (0).float_p)
+  icode = code_for_mve_vld1q_f(e.vector_mode (0));
+else
+  {
+   if (e.type_suffix (0).unsigned_p)
+ icode = code_for_mve_vld1q(VLD1Q_U,
+e.vector_mode (0));
+   else
+ icode = code_for_mve_vld1q(VLD1Q_S,
+e.vector_mode (0));
+  }
+return e.use_contiguous_load_insn (icode);
+  }
+};
+
+class vst1_impl : public full_width_access
+{
+public:
+  unsigned int
+  call_properties (const function_instance &) const override
+  {
+return CP_WRITE_MEMORY;
+  }
+
+  rtx
+  expand (function_expander ) const override
+  {
+insn_code icode;
+if (e.type_suffix (0).float_p)
+  icode = code_for_mve_vst1q_f(e.vector_mode (0));
+else
+  {
+   if (e.type_suffix (0).unsigned_p)
+ icode = code_for_mve_vst1q(VST1Q_U,
+e.vector_mode (0));
+   else
+ icode = code_for_mve_vst1q(VST1Q_S,
+e.vector_mode (0));
+  }
+return e.use_contiguous_store_insn (icode);
+  }
+};
+
 } /* end anonymous namespace */
 
 namespace arm_mve {
@@ -290,6 +346,7 @@ FUNCTION (vfmasq, unspec_mve_function_exact_insn, (-1, -1, 
-1, -1, -1, VFMASQ_N_
 FUNCTION (vfmsq, unspec_mve_function_exact_insn, (-1, -1, VFMSQ_F, -1, -1, -1, 
-1, -1, VFMSQ_M_F, -1, -1, -1))
 FUNCTION_WITH_M_N_NO_F (vhaddq, VHADDQ)
 FUNCTION_WITH_M_N_NO_F (vhsubq, VHSUBQ)
+FUNCTION (vld1q, vld1_impl,)
 FUNCTION_PRED_P_S (vmaxavq, VMAXAVQ)
 FUNCTION_WITHOUT_N_NO_U_F (vmaxaq, VMAXAQ)
 FUNCTION_ONLY_F (vmaxnmaq, VMAXNMAQ)
@@ -405,6 +462,7 @@ FUNCTION_ONLY_N_NO_F (vshrntq, VSHRNTQ)
 FUNCTION_ONLY_N_NO_F (vshrq, VSHRQ)
 FUNCTION_ONLY_N_NO_F (vsliq, VSLIQ)
 FUNCTION_ONLY_N_NO_F (vsriq, VSRIQ)
+FUNCTION (vst1q, vst1_impl,)
 FUNCTION_WITH_RTX_M_N (vsubq, MINUS, VSUBQ)
 FUNCTION (vuninitializedq, vuninitializedq_impl,)
 
diff --git a/gcc/config/arm/arm-mve-builtins-base.def 
b/gcc/config/arm/arm-mve-builtins-base.def
index 01dfbdef8a3..16879246237 100644
--- a/gcc/config/arm/arm-mve-builtins-base.def
+++ b/gcc/config/arm/arm-mve-builtins-base.def
@@ -47,6 +47,7 @@ DEF_MVE_FUNCTION (vhaddq, binary_opt_n, all_integer, 
mx_or_none)
 DEF_MVE_FUNCTION (vhcaddq_rot90, binary, all_signed,