Patchwork [ARM,2/3] Add vectorization support for rounding functions

login
register
mail settings
Submitter Kyrylo Tkachov
Date Dec. 18, 2012, 1:33 p.m.
Message ID <002601cddd24$47dfc1a0$d79f44e0$@tkachov@arm.com>
Download mbox | patch
Permalink /patch/207114/
State New
Headers show

Comments

Kyrylo Tkachov - Dec. 18, 2012, 1:33 p.m.
Hi all,

This patch adds support for the vectorisation of the rounding functions:
floorf, ceilf, truncf, roundf. These can be implemented using the ARMv8 NEON
instructions: vrintm, vrintp, vrintz, vrinta.
This is done by defining the TARGET_VECTORIZE_BUILTINS and
TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION macros and the function
arm_builtin_vectorized_function that returns the decl of the vector form
of a builtin function, or NULL_TREE if no vector variant exists.

No regressions on arm-none-eabi with AEM.

Ok for trunk?

gcc/ChangeLog

2012-12-18  Kyrylo Tkachov  <kyrylo.tkachov at arm.com>

	* config/arm/arm-protos.h (arm_builtin_vectorized_function):
	  New function prototype.
	* config/arm/arm.c (TARGET_VECTORIZE_BUILTINS): Define.
	  (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise.
	  (arm_builtin_vectorized_function): New function.
Kyrylo Tkachov - Jan. 7, 2013, 10:34 a.m.
Ping.

http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01113.html

Thanks,
Kyrill

> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> owner@gcc.gnu.org] On Behalf Of Kyrylo Tkachov
> Sent: 18 December 2012 13:34
> To: gcc-patches@gcc.gnu.org
> Cc: Ramana Radhakrishnan; Richard Earnshaw
> Subject: [PATCH][ARM][2/3] Add vectorization support for rounding
> functions
> 
> Hi all,
> 
> This patch adds support for the vectorisation of the rounding
> functions:
> floorf, ceilf, truncf, roundf. These can be implemented using the ARMv8
> NEON
> instructions: vrintm, vrintp, vrintz, vrinta.
> This is done by defining the TARGET_VECTORIZE_BUILTINS and
> TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION macros and the function
> arm_builtin_vectorized_function that returns the decl of the vector
> form
> of a builtin function, or NULL_TREE if no vector variant exists.
> 
> No regressions on arm-none-eabi with AEM.
> 
> Ok for trunk?
> 
> gcc/ChangeLog
> 
> 2012-12-18  Kyrylo Tkachov  <kyrylo.tkachov at arm.com>
> 
> 	* config/arm/arm-protos.h (arm_builtin_vectorized_function):
> 	  New function prototype.
> 	* config/arm/arm.c (TARGET_VECTORIZE_BUILTINS): Define.
> 	  (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise.
> 	  (arm_builtin_vectorized_function): New function.
Kyrylo Tkachov - Jan. 14, 2013, 5:32 p.m.
Ping.

Thanks,
Kyrill

> -----Original Message-----
> From: Kyrylo Tkachov
> Sent: 07 January 2013 10:35
> To: Kyrylo Tkachov; gcc-patches@gcc.gnu.org
> Cc: Ramana Radhakrishnan; Richard Earnshaw
> Subject: RE: [PATCH][ARM][2/3] Add vectorization support for rounding
> functions
> 
> Ping.
> 
> http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01113.html
> 
> Thanks,
> Kyrill
> 
> > -----Original Message-----
> > From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> > owner@gcc.gnu.org] On Behalf Of Kyrylo Tkachov
> > Sent: 18 December 2012 13:34
> > To: gcc-patches@gcc.gnu.org
> > Cc: Ramana Radhakrishnan; Richard Earnshaw
> > Subject: [PATCH][ARM][2/3] Add vectorization support for rounding
> > functions
> >
> > Hi all,
> >
> > This patch adds support for the vectorisation of the rounding
> > functions:
> > floorf, ceilf, truncf, roundf. These can be implemented using the
> ARMv8
> > NEON
> > instructions: vrintm, vrintp, vrintz, vrinta.
> > This is done by defining the TARGET_VECTORIZE_BUILTINS and
> > TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION macros and the function
> > arm_builtin_vectorized_function that returns the decl of the vector
> > form
> > of a builtin function, or NULL_TREE if no vector variant exists.
> >
> > No regressions on arm-none-eabi with AEM.
> >
> > Ok for trunk?
> >
> > gcc/ChangeLog
> >
> > 2012-12-18  Kyrylo Tkachov  <kyrylo.tkachov at arm.com>
> >
> > 	* config/arm/arm-protos.h (arm_builtin_vectorized_function):
> > 	  New function prototype.
> > 	* config/arm/arm.c (TARGET_VECTORIZE_BUILTINS): Define.
> > 	  (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise.
> > 	  (arm_builtin_vectorized_function): New function.
>
Kyrylo Tkachov - Jan. 22, 2013, 5:09 p.m.
Ping^3?

Thanks,
Kyrill

> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> owner@gcc.gnu.org] On Behalf Of Kyrylo Tkachov
> Sent: 14 January 2013 17:32
> To: gcc-patches@gcc.gnu.org
> Cc: Ramana Radhakrishnan; Richard Earnshaw
> Subject: RE: [PATCH][ARM][2/3] Add vectorization support for rounding
> functions
> 
> Ping.
> 
> Thanks,
> Kyrill
> 
> > -----Original Message-----
> > From: Kyrylo Tkachov
> > Sent: 07 January 2013 10:35
> > To: Kyrylo Tkachov; gcc-patches@gcc.gnu.org
> > Cc: Ramana Radhakrishnan; Richard Earnshaw
> > Subject: RE: [PATCH][ARM][2/3] Add vectorization support for rounding
> > functions
> >
> > Ping.
> >
> > http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01113.html
> >
> > Thanks,
> > Kyrill
> >
> > > -----Original Message-----
> > > From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> > > owner@gcc.gnu.org] On Behalf Of Kyrylo Tkachov
> > > Sent: 18 December 2012 13:34
> > > To: gcc-patches@gcc.gnu.org
> > > Cc: Ramana Radhakrishnan; Richard Earnshaw
> > > Subject: [PATCH][ARM][2/3] Add vectorization support for rounding
> > > functions
> > >
> > > Hi all,
> > >
> > > This patch adds support for the vectorisation of the rounding
> > > functions:
> > > floorf, ceilf, truncf, roundf. These can be implemented using the
> > ARMv8
> > > NEON
> > > instructions: vrintm, vrintp, vrintz, vrinta.
> > > This is done by defining the TARGET_VECTORIZE_BUILTINS and
> > > TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION macros and the
> function
> > > arm_builtin_vectorized_function that returns the decl of the vector
> > > form
> > > of a builtin function, or NULL_TREE if no vector variant exists.
> > >
> > > No regressions on arm-none-eabi with AEM.
> > >
> > > Ok for trunk?
> > >
> > > gcc/ChangeLog
> > >
> > > 2012-12-18  Kyrylo Tkachov  <kyrylo.tkachov at arm.com>
> > >
> > > 	* config/arm/arm-protos.h (arm_builtin_vectorized_function):
> > > 	  New function prototype.
> > > 	* config/arm/arm.c (TARGET_VECTORIZE_BUILTINS): Define.
> > > 	  (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise.
> > > 	  (arm_builtin_vectorized_function): New function.
> >
> 
> 
> 
>
Kyrylo Tkachov - Feb. 5, 2013, 2:10 p.m.
Ping?

Thanks,
Kyrill

> -----Original Message-----
> From: Kyrylo Tkachov [mailto:kyrylo.tkachov@arm.com]
> Sent: 07 January 2013 10:35
> To: Kyrylo Tkachov; gcc-patches@gcc.gnu.org
> Cc: Ramana Radhakrishnan; Richard Earnshaw
> Subject: RE: [PATCH][ARM][2/3] Add vectorization support for rounding
> functions
> 
> Ping.
> 
> http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01113.html
> 
> Thanks,
> Kyrill
> 
> > -----Original Message-----
> > From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> > owner@gcc.gnu.org] On Behalf Of Kyrylo Tkachov
> > Sent: 18 December 2012 13:34
> > To: gcc-patches@gcc.gnu.org
> > Cc: Ramana Radhakrishnan; Richard Earnshaw
> > Subject: [PATCH][ARM][2/3] Add vectorization support for rounding
> > functions
> >
> > Hi all,
> >
> > This patch adds support for the vectorisation of the rounding
> > functions:
> > floorf, ceilf, truncf, roundf. These can be implemented using the
> ARMv8
> > NEON
> > instructions: vrintm, vrintp, vrintz, vrinta.
> > This is done by defining the TARGET_VECTORIZE_BUILTINS and
> > TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION macros and the function
> > arm_builtin_vectorized_function that returns the decl of the vector
> > form
> > of a builtin function, or NULL_TREE if no vector variant exists.
> >
> > No regressions on arm-none-eabi with AEM.
> >
> > Ok for trunk?
> >
> > gcc/ChangeLog
> >
> > 2012-12-18  Kyrylo Tkachov  <kyrylo.tkachov at arm.com>
> >
> > 	* config/arm/arm-protos.h (arm_builtin_vectorized_function):
> > 	  New function prototype.
> > 	* config/arm/arm.c (TARGET_VECTORIZE_BUILTINS): Define.
> > 	  (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise.
> > 	  (arm_builtin_vectorized_function): New function.
Ramana Radhakrishnan - Feb. 6, 2013, 9:58 a.m.
On 12/18/12 13:33, Kyrylo Tkachov wrote:
> Hi all,
>
> This patch adds support for the vectorisation of the rounding functions:
> floorf, ceilf, truncf, roundf. These can be implemented using the ARMv8 NEON
> instructions: vrintm, vrintp, vrintz, vrinta.
> This is done by defining the TARGET_VECTORIZE_BUILTINS and
> TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION macros and the function
> arm_builtin_vectorized_function that returns the decl of the vector form
> of a builtin function, or NULL_TREE if no vector variant exists.
>
> No regressions on arm-none-eabi with AEM.
>
> Ok for trunk?
>
> gcc/ChangeLog
>
> 2012-12-18  Kyrylo Tkachov  <kyrylo.tkachov at arm.com>
>
> 	* config/arm/arm-protos.h (arm_builtin_vectorized_function):
> 	  New function prototype.
> 	* config/arm/arm.c (TARGET_VECTORIZE_BUILTINS): Define.
> 	  (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise.
> 	  (arm_builtin_vectorized_function): New function.
>


Ok for stage1.

regards
Ramana

Patch

diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index d942c5b..0754066 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -80,6 +80,7 @@  extern char *neon_output_shift_immediate (const char *, char, rtx *,
 extern void neon_pairwise_reduce (rtx, rtx, enum machine_mode,
 				  rtx (*) (rtx, rtx, rtx));
 extern rtx neon_make_constant (rtx);
+extern tree arm_builtin_vectorized_function (tree, tree, tree);
 extern void neon_expand_vector_init (rtx, rtx);
 extern void neon_lane_bounds (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
 extern void neon_const_bounds (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 84ce56f..8193e4f 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -607,6 +607,13 @@  static const struct attribute_spec arm_attribute_table[] =
 #undef TARGET_CLASS_LIKELY_SPILLED_P
 #define TARGET_CLASS_LIKELY_SPILLED_P arm_class_likely_spilled_p
 
+#undef TARGET_VECTORIZE_BUILTINS
+#define TARGET_VECTORIZE_BUILTINS
+
+#undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
+#define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
+  arm_builtin_vectorized_function
+
 #undef TARGET_VECTOR_ALIGNMENT
 #define TARGET_VECTOR_ALIGNMENT arm_vector_alignment
 
@@ -25593,6 +25600,60 @@  arm_have_conditional_execution (void)
   return !TARGET_THUMB1;
 }
 
+tree
+arm_builtin_vectorized_function (tree fndecl, tree type_out, tree type_in)
+{
+  enum machine_mode in_mode, out_mode;
+  int in_n, out_n;
+
+  if (TREE_CODE (type_out) != VECTOR_TYPE
+      || TREE_CODE (type_in) != VECTOR_TYPE
+      || !(TARGET_NEON && TARGET_FPU_ARMV8 && flag_unsafe_math_optimizations))
+    return NULL_TREE;
+
+  out_mode = TYPE_MODE (TREE_TYPE (type_out));
+  out_n = TYPE_VECTOR_SUBPARTS (type_out);
+  in_mode = TYPE_MODE (TREE_TYPE (type_in));
+  in_n = TYPE_VECTOR_SUBPARTS (type_in);
+
+/* ARM_CHECK_BUILTIN_MODE and ARM_FIND_VRINT_VARIANT are used to find the
+   decl of the vectorized builtin for the appropriate vector mode.
+   NULL_TREE is returned if no such builtin is available.  */
+#undef ARM_CHECK_BUILTIN_MODE
+#define ARM_CHECK_BUILTIN_MODE(C) \
+  (out_mode == SFmode && out_n == C \
+   && in_mode == SFmode && in_n == C)
+
+#undef ARM_FIND_VRINT_VARIANT
+#define ARM_FIND_VRINT_VARIANT(N) \
+  (ARM_CHECK_BUILTIN_MODE (2) \
+    ? arm_builtin_decl(ARM_BUILTIN_NEON_##N##v2sf, false) \
+    : (ARM_CHECK_BUILTIN_MODE (4) \
+      ? arm_builtin_decl(ARM_BUILTIN_NEON_##N##v4sf, false) \
+      : NULL_TREE))
+
+  if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+    {
+      enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
+      switch (fn)
+        {
+          case BUILT_IN_FLOORF:
+            return ARM_FIND_VRINT_VARIANT (vrintm);
+          case BUILT_IN_CEILF:
+            return ARM_FIND_VRINT_VARIANT (vrintp);
+          case BUILT_IN_TRUNCF:
+            return ARM_FIND_VRINT_VARIANT (vrintz);
+          case BUILT_IN_ROUNDF:
+            return ARM_FIND_VRINT_VARIANT (vrinta);
+          default:
+            return NULL_TREE;
+        }
+    }
+  return NULL_TREE;
+}
+#undef ARM_CHECK_BUILTIN_MODE
+#undef ARM_FIND_VRINT_VARIANT
+
 /* The AAPCS sets the maximum alignment of a vector to 64 bits.  */
 static HOST_WIDE_INT
 arm_vector_alignment (const_tree type)