[ARM,NEON] PR66791: Replace builtins in vceq_* (a, b) with a == b.

Message ID CAAgBjMknFX==3sX6y3CDUFvVhDaNs+si7gO3eR7g8+36AfWc6Q@mail.gmail.com
State New
Headers show
Series
  • [ARM,NEON] PR66791: Replace builtins in vceq_* (a, b) with a == b.
Related show

Commit Message

H.J. Lu via Gcc-patches June 9, 2021, 9:19 a.m.
Hi,
The attached patch replaces calls to _builtin_neon_vceq<type> (a, b) with a == b
for integral variants, and for fp variants it gates the equality
comparison on __FAST_MATH__ because for fp variants a == b results in
much longer
code than __builtin_neon_vceqv2sf. which simply emits vceq.f32.
However both produce vceq.f32 with -ffast-math.

Thanks,
Prathamesh
2021-06-09  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	* config/arm/arm_neon.h (vceq_s8): Replace builtin with __a == __b.
	(vceq_s16): Likewise.
	(vceq_s32): Likewise.
	(vceq_u8): Likewise.
	(vceq_u16): Likewise.
	(vceq_u32): Likewise.
	(vceq_p8): Likewise.
	(vceqq_s8): Likewise.
	(vceqq_s16): Likewise.
	(vceqq_s32): Likewise.
	(vceqq_u8): Likewise.
	(vceqq_u16): Likewise.
	(vceqq_u32): Likewise.
	(vceqq_p8): Likewise.
	(vceq_f32): Gate __a == __b on __FAST_MATH__.
	(vceqq_f32): Likewise.
	(vceq_f16): Likewise.
	(vceqq_f16): Likewise.

Comments

H.J. Lu via Gcc-patches June 14, 2021, 7:59 a.m. | #1
On Wed, 9 Jun 2021 at 14:49, Prathamesh Kulkarni
<prathamesh.kulkarni@linaro.org> wrote:
>

> Hi,

> The attached patch replaces calls to _builtin_neon_vceq<type> (a, b) with a == b

> for integral variants, and for fp variants it gates the equality

> comparison on __FAST_MATH__ because for fp variants a == b results in

> much longer

> code than __builtin_neon_vceqv2sf. which simply emits vceq.f32.

> However both produce vceq.f32 with -ffast-math.

ping https://gcc.gnu.org/pipermail/gcc-patches/2021-June/572338.html

Thanks,
Prathamesh
>

> Thanks,

> Prathamesh
H.J. Lu via Gcc-patches June 14, 2021, 10:46 a.m. | #2
> -----Original Message-----

> From: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>

> Sent: 14 June 2021 08:59

> To: gcc Patches <gcc-patches@gcc.gnu.org>; Kyrylo Tkachov

> <Kyrylo.Tkachov@arm.com>

> Subject: Re: [ARM NEON] PR66791: Replace builtins in vceq_* (a, b) with a ==

> b.

> 

> On Wed, 9 Jun 2021 at 14:49, Prathamesh Kulkarni

> <prathamesh.kulkarni@linaro.org> wrote:

> >

> > Hi,

> > The attached patch replaces calls to _builtin_neon_vceq<type> (a, b) with a

> == b

> > for integral variants, and for fp variants it gates the equality

> > comparison on __FAST_MATH__ because for fp variants a == b results in

> > much longer

> > code than __builtin_neon_vceqv2sf. which simply emits vceq.f32.

> > However both produce vceq.f32 with -ffast-math.

> ping https://gcc.gnu.org/pipermail/gcc-patches/2021-June/572338.html

> 


Ok.
Thanks,
Kyrill

> Thanks,

> Prathamesh

> >

> > Thanks,

> > Prathamesh

Patch

diff --git a/gcc/config/arm/arm_neon.h b/gcc/config/arm/arm_neon.h
index dcd533fd003..7a800062f9e 100644
--- a/gcc/config/arm/arm_neon.h
+++ b/gcc/config/arm/arm_neon.h
@@ -2359,112 +2359,120 @@  __extension__ extern __inline uint8x8_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_s8 (int8x8_t __a, int8x8_t __b)
 {
-  return (uint8x8_t)__builtin_neon_vceqv8qi (__a, __b);
+  return (uint8x8_t) (__a == __b);
 }
 
 __extension__ extern __inline uint16x4_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_s16 (int16x4_t __a, int16x4_t __b)
 {
-  return (uint16x4_t)__builtin_neon_vceqv4hi (__a, __b);
+  return (uint16x4_t) (__a == __b);
 }
 
 __extension__ extern __inline uint32x2_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_s32 (int32x2_t __a, int32x2_t __b)
 {
-  return (uint32x2_t)__builtin_neon_vceqv2si (__a, __b);
+  return (uint32x2_t) (__a == __b);
 }
 
 __extension__ extern __inline uint32x2_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_f32 (float32x2_t __a, float32x2_t __b)
 {
+#ifdef __FAST_MATH__
+  return (uint32x2_t) (__a == __b);
+#else
   return (uint32x2_t)__builtin_neon_vceqv2sf (__a, __b);
+#endif
 }
 
 __extension__ extern __inline uint8x8_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_u8 (uint8x8_t __a, uint8x8_t __b)
 {
-  return (uint8x8_t)__builtin_neon_vceqv8qi ((int8x8_t) __a, (int8x8_t) __b);
+  return (uint8x8_t) (__a == __b);
 }
 
 __extension__ extern __inline uint16x4_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_u16 (uint16x4_t __a, uint16x4_t __b)
 {
-  return (uint16x4_t)__builtin_neon_vceqv4hi ((int16x4_t) __a, (int16x4_t) __b);
+  return (uint16x4_t) (__a == __b);
 }
 
 __extension__ extern __inline uint32x2_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_u32 (uint32x2_t __a, uint32x2_t __b)
 {
-  return (uint32x2_t)__builtin_neon_vceqv2si ((int32x2_t) __a, (int32x2_t) __b);
+  return (uint32x2_t) (__a == __b);
 }
 
 __extension__ extern __inline uint8x8_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_p8 (poly8x8_t __a, poly8x8_t __b)
 {
-  return (uint8x8_t)__builtin_neon_vceqv8qi ((int8x8_t) __a, (int8x8_t) __b);
+  return (uint8x8_t) (__a == __b);
 }
 
 __extension__ extern __inline uint8x16_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_s8 (int8x16_t __a, int8x16_t __b)
 {
-  return (uint8x16_t)__builtin_neon_vceqv16qi (__a, __b);
+  return (uint8x16_t) (__a == __b);
 }
 
 __extension__ extern __inline uint16x8_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_s16 (int16x8_t __a, int16x8_t __b)
 {
-  return (uint16x8_t)__builtin_neon_vceqv8hi (__a, __b);
+  return (uint16x8_t) (__a == __b);
 }
 
 __extension__ extern __inline uint32x4_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_s32 (int32x4_t __a, int32x4_t __b)
 {
-  return (uint32x4_t)__builtin_neon_vceqv4si (__a, __b);
+  return (uint32x4_t) (__a == __b);
 }
 
 __extension__ extern __inline uint32x4_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_f32 (float32x4_t __a, float32x4_t __b)
 {
+#ifdef __FAST_MATH__
+  return (uint32x4_t) (__a == __b);
+#else
   return (uint32x4_t)__builtin_neon_vceqv4sf (__a, __b);
+#endif
 }
 
 __extension__ extern __inline uint8x16_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_u8 (uint8x16_t __a, uint8x16_t __b)
 {
-  return (uint8x16_t)__builtin_neon_vceqv16qi ((int8x16_t) __a, (int8x16_t) __b);
+  return (uint8x16_t) (__a == __b);
 }
 
 __extension__ extern __inline uint16x8_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_u16 (uint16x8_t __a, uint16x8_t __b)
 {
-  return (uint16x8_t)__builtin_neon_vceqv8hi ((int16x8_t) __a, (int16x8_t) __b);
+  return (uint16x8_t) (__a == __b);
 }
 
 __extension__ extern __inline uint32x4_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_u32 (uint32x4_t __a, uint32x4_t __b)
 {
-  return (uint32x4_t)__builtin_neon_vceqv4si ((int32x4_t) __a, (int32x4_t) __b);
+  return (uint32x4_t) (__a == __b);
 }
 
 __extension__ extern __inline uint8x16_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_p8 (poly8x16_t __a, poly8x16_t __b)
 {
-  return (uint8x16_t)__builtin_neon_vceqv16qi ((int8x16_t) __a, (int8x16_t) __b);
+  return (uint8x16_t) (__a == __b);
 }
 
 __extension__ extern __inline uint8x8_t
@@ -17195,14 +17203,22 @@  __extension__ extern __inline uint16x4_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceq_f16 (float16x4_t __a, float16x4_t __b)
 {
+#ifdef __FAST_MATH__
+  return (uint16x4_t) (__a == __b);
+#else
   return (uint16x4_t)__builtin_neon_vceqv4hf (__a, __b);
+#endif
 }
 
 __extension__ extern __inline uint16x8_t
 __attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
 vceqq_f16 (float16x8_t __a, float16x8_t __b)
 {
+#ifdef __FAST_MATH__
+  return (uint16x8_t) (__a == __b);
+#else
   return (uint16x8_t)__builtin_neon_vceqv8hf (__a, __b);
+#endif
 }
 
 __extension__ extern __inline uint16x4_t