diff mbox

[v2,AArch32,NEON] Implementing vmaxnmQ_ST and vminnmQ_ST intrinsincs.

Message ID VI1PR0801MB2031338DB3CA0BF8746CB587FFD20@VI1PR0801MB2031.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Tamar Christina Oct. 19, 2016, 9:36 a.m. UTC
Hi All,

This patch implements the vmaxnmQ_ST and vminnmQ_ST intrinsics. The
current builtin registration code is deficient since it can't access
standard pattern names, to which vmaxnmQ_ST and vminnmQ_ST map
directly. Thus, to enable the vectoriser to have access to these
intrinsics, we implement them using builtin functions, which we 
expand to the proper standard pattern using a define_expand.

This patch also implements the __ARM_FEATURE_NUMERIC_MAXMIN macro, 
which is defined when __ARM_ARCH >= 8, and which enables the 
intrinsics.

Regression tested on arm-none-eabi and no regressions.

This patch is a rework of a previous patch:
https://gcc.gnu.org/ml/gcc-patches/2015-12/msg01971.html

OK for trunk?

Thanks,
Tamar

---

gcc/

2016-10-19  Bilyan Borisov  <bilyan.borisov@arm.com>
	    Tamar Christina <tamar.christina@arm.com>

	* config/arm/arm-c.c (arm_cpu_builtins): New macro definition.
	* config/arm/arm_neon.h (vmaxnm_f32): New intrinsinc.
	(vmaxnmq_f32): Likewise.
	(vminnm_f32): Likewise.
	(vminnmq_f32): Likewise.
	* config/arm/arm_neon_builtins.def (vmaxnm): New builtin.
	(vminnm): Likewise.
	* config/arm/neon.md (neon_<fmaxmin_op><mode>, VCVTF): New
	expander.

gcc/testsuite/

2016-10-19  Bilyan Borisov  <bilyan.borisov@arm.com>

	* gcc.target/arm/simd/vmaxnm_f32_1.c: New.
	* gcc.target/arm/simd/vmaxnmq_f32_1.c: Likewise.
	* gcc.target/arm/simd/vminnm_f32_1.c: Likewise.
	* gcc.target/arm/simd/vminnmq_f32_1.c: Likewise.

Comments

Christophe Lyon Oct. 19, 2016, 10:23 a.m. UTC | #1
On 19 October 2016 at 11:36, Tamar Christina <Tamar.Christina@arm.com> wrote:
> Hi All,

>

> This patch implements the vmaxnmQ_ST and vminnmQ_ST intrinsics. The

> current builtin registration code is deficient since it can't access

> standard pattern names, to which vmaxnmQ_ST and vminnmQ_ST map

> directly. Thus, to enable the vectoriser to have access to these

> intrinsics, we implement them using builtin functions, which we

> expand to the proper standard pattern using a define_expand.

>

> This patch also implements the __ARM_FEATURE_NUMERIC_MAXMIN macro,

> which is defined when __ARM_ARCH >= 8, and which enables the

> intrinsics.

>

> Regression tested on arm-none-eabi and no regressions.

>

> This patch is a rework of a previous patch:

> https://gcc.gnu.org/ml/gcc-patches/2015-12/msg01971.html

>

> OK for trunk?

>

> Thanks,

> Tamar

>

> ---

>

> gcc/

>

> 2016-10-19  Bilyan Borisov  <bilyan.borisov@arm.com>

>             Tamar Christina <tamar.christina@arm.com>

>

>         * config/arm/arm-c.c (arm_cpu_builtins): New macro definition.

>         * config/arm/arm_neon.h (vmaxnm_f32): New intrinsinc.

>         (vmaxnmq_f32): Likewise.

>         (vminnm_f32): Likewise.

>         (vminnmq_f32): Likewise.

>         * config/arm/arm_neon_builtins.def (vmaxnm): New builtin.

>         (vminnm): Likewise.

>         * config/arm/neon.md (neon_<fmaxmin_op><mode>, VCVTF): New

>         expander.

>

> gcc/testsuite/

>

> 2016-10-19  Bilyan Borisov  <bilyan.borisov@arm.com>

>

>         * gcc.target/arm/simd/vmaxnm_f32_1.c: New.

>         * gcc.target/arm/simd/vmaxnmq_f32_1.c: Likewise.

>         * gcc.target/arm/simd/vminnm_f32_1.c: Likewise.

>         * gcc.target/arm/simd/vminnmq_f32_1.c: Likewise.

>


I think you forgot to attach the new tests.

Christophe
Tamar Christina Oct. 19, 2016, 10:39 a.m. UTC | #2
________________________________________
> I think you forgot to attach the new tests.


Ah, you're right! forgot an add.

New patch coming soon.

Thanks,
Tamar
diff mbox

Patch

diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c
index 72837001d1011e366233236a6ba3d1e5775583b1..dcb883d750506a02257e6e2e49880f2d1b9888fa 100644
--- a/gcc/config/arm/arm-c.c
+++ b/gcc/config/arm/arm-c.c
@@ -86,6 +86,9 @@  arm_cpu_builtins (struct cpp_reader* pfile)
 		      ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB)
 		       || TARGET_ARM_ARCH_ISA_THUMB >=2));
 
+  def_or_undef_macro (pfile, "__ARM_FEATURE_NUMERIC_MAXMIN",
+		      TARGET_ARM_ARCH >= 8 && TARGET_NEON && TARGET_FPU_ARMV8);
+
   def_or_undef_macro (pfile, "__ARM_FEATURE_SIMD32", TARGET_INT_SIMD);
 
   builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM",
diff --git a/gcc/config/arm/arm_neon.h b/gcc/config/arm/arm_neon.h
index 54bbc7dd83cf979b6fad7724ba1d4b327b311f5c..3898ff7302dc3f21e6b50a8a7b835033c1ae2021 100644
--- a/gcc/config/arm/arm_neon.h
+++ b/gcc/config/arm/arm_neon.h
@@ -2956,6 +2956,34 @@  vmaxq_f32 (float32x4_t __a, float32x4_t __b)
   return (float32x4_t)__builtin_neon_vmaxfv4sf (__a, __b);
 }
 
+#pragma GCC push_options
+#pragma GCC target ("fpu=neon-fp-armv8")
+__extension__ static __inline float32x2_t __attribute__ ((__always_inline__))
+vmaxnm_f32 (float32x2_t a, float32x2_t b)
+{
+  return (float32x2_t)__builtin_neon_vmaxnmv2sf (a, b);
+}
+
+__extension__ static __inline float32x4_t __attribute__ ((__always_inline__))
+vmaxnmq_f32 (float32x4_t a, float32x4_t b)
+{
+  return (float32x4_t)__builtin_neon_vmaxnmv4sf (a, b);
+}
+
+__extension__ static __inline float32x2_t __attribute__ ((__always_inline__))
+vminnm_f32 (float32x2_t a, float32x2_t b)
+{
+  return (float32x2_t)__builtin_neon_vminnmv2sf (a, b);
+}
+
+__extension__ static __inline float32x4_t __attribute__ ((__always_inline__))
+vminnmq_f32 (float32x4_t a, float32x4_t b)
+{
+  return (float32x4_t)__builtin_neon_vminnmv4sf (a, b);
+}
+#pragma GCC pop_options
+
+
 __extension__ static __inline uint8x16_t __attribute__ ((__always_inline__))
 vmaxq_u8 (uint8x16_t __a, uint8x16_t __b)
 {
diff --git a/gcc/config/arm/arm_neon_builtins.def b/gcc/config/arm/arm_neon_builtins.def
index b29aa91a64ecb85dfb5eb9661ed67d4fa326062f..58b10207c1f5c0380cb01fdb4a92a3f0b4dec591 100644
--- a/gcc/config/arm/arm_neon_builtins.def
+++ b/gcc/config/arm/arm_neon_builtins.def
@@ -147,12 +147,12 @@  VAR6 (BINOP, vmaxs, v8qi, v4hi, v2si, v16qi, v8hi, v4si)
 VAR6 (BINOP, vmaxu, v8qi, v4hi, v2si, v16qi, v8hi, v4si)
 VAR2 (BINOP, vmaxf, v2sf, v4sf)
 VAR2 (BINOP, vmaxf, v8hf, v4hf)
-VAR2 (BINOP, vmaxnm, v4hf, v8hf)
+VAR4 (BINOP, vmaxnm, v2sf, v4sf, v4hf, v8hf)
 VAR6 (BINOP, vmins, v8qi, v4hi, v2si, v16qi, v8hi, v4si)
 VAR6 (BINOP, vminu, v8qi, v4hi, v2si, v16qi, v8hi, v4si)
 VAR2 (BINOP, vminf, v2sf, v4sf)
 VAR2 (BINOP, vminf, v4hf, v8hf)
-VAR2 (BINOP, vminnm, v8hf, v4hf)
+VAR4 (BINOP, vminnm, v2sf, v4sf, v8hf, v4hf)
 
 VAR3 (BINOP, vpmaxs, v8qi, v4hi, v2si)
 VAR3 (BINOP, vpmaxu, v8qi, v4hi, v2si)
diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
index 05323334ffd81aeff33ee407b96c788d123b3fe3..3ae4f6a3bf26032f4c34d83ff79e27b30d4000de 100644
--- a/gcc/config/arm/neon.md
+++ b/gcc/config/arm/neon.md
@@ -2841,6 +2841,18 @@ 
  [(set_attr "type" "neon_fp_minmax_s<q>")]
 )
 
+;; Expander for v<maxmin>nm intrinsics.
+(define_expand "neon_<fmaxmin_op><mode>"
+  [(unspec:VCVTF [(match_operand:VCVTF 0 "s_register_operand" "")
+   (match_operand:VCVTF 1 "s_register_operand" "")
+   (match_operand:VCVTF 2 "s_register_operand" "")]
+		  VMAXMINFNM)]
+  "TARGET_NEON && TARGET_FPU_ARMV8"
+{
+  emit_insn (gen_<fmaxmin><mode>3 (operands[0], operands[1], operands[2]));
+  DONE;
+})
+
 ;; Vector forms for the IEEE-754 fmax()/fmin() functions
 (define_insn "<fmaxmin><mode>3"
   [(set (match_operand:VCVTF 0 "s_register_operand" "=w")