[PATCH] aarch64: Use type-qualified builtins for UHSUB Neon intrinsics

Richard Sandiford richard.sandiford@arm.com
Thu Nov 11 10:28:45 GMT 2021


Jonathan Wright <Jonathan.Wright@arm.com> writes:
> Hi,
>
> This patch declares unsigned type-qualified builtins and uses them to
> implement halving-subtract Neon intrinsics. This removes the need for
> many casts in arm_neon.h.
>
> Bootstrapped and regression tested on aarch64-none-linux-gnu - no
> issues.
>
> Ok for master?
>
> Thanks,
> Jonathan
>
> ---
>
> gcc/ChangeLog:
>
> 2021-11-09  Jonathan Wright  <jonathan.wright@arm.com>
>
>         * config/aarch64/aarch64-simd-builtins.def: Use BINOPU type
>         qualifiers in generator macros for uhsub builtins.
>         * config/aarch64/arm_neon.h (vhsub_s8): Remove unnecessary
>         cast.
>         (vhsub_s16): Likewise.
>         (vhsub_s32): Likewise.
>         (vhsub_u8): Use type-qualified builtin and remove casts.
>         (vhsub_u16): Likewise.
>         (vhsub_u32): Likewise.
>         (vhsubq_s8): Remove unnecessary cast.
>         (vhsubq_s16): Likewise.
>         (vhsubq_s32): Likewise.
>         (vhsubq_u8): Use type-qualified builtin and remove casts.
>         (vhsubq_u16): Likewise.
>         (vhsubq_u32): Likewise.

OK, thanks.

Richard

> diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def b/gcc/config/aarch64/aarch64-simd-builtins.def
> index 8f9a8d1707dfdf6111d740da53275e79500e8cde..af04b732227439dcaaa2f3751097050d988eb729 100644
> --- a/gcc/config/aarch64/aarch64-simd-builtins.def
> +++ b/gcc/config/aarch64/aarch64-simd-builtins.def
> @@ -179,7 +179,7 @@
>    BUILTIN_VDQ_BHSI (BINOP, shadd, 0, NONE)
>    BUILTIN_VDQ_BHSI (BINOP, shsub, 0, NONE)
>    BUILTIN_VDQ_BHSI (BINOPU, uhadd, 0, NONE)
> -  BUILTIN_VDQ_BHSI (BINOP, uhsub, 0, NONE)
> +  BUILTIN_VDQ_BHSI (BINOPU, uhsub, 0, NONE)
>    BUILTIN_VDQ_BHSI (BINOP, srhadd, 0, NONE)
>    BUILTIN_VDQ_BHSI (BINOPU, urhadd, 0, NONE)
>  
> diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h
> index 73eea7c261f49155d616a2ddf1d96d4be9bca53f..b2781f680d142b848f622d2f4965b42985885502 100644
> --- a/gcc/config/aarch64/arm_neon.h
> +++ b/gcc/config/aarch64/arm_neon.h
> @@ -1956,90 +1956,84 @@ __extension__ extern __inline int8x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsub_s8 (int8x8_t __a, int8x8_t __b)
>  {
> -  return (int8x8_t)__builtin_aarch64_shsubv8qi (__a, __b);
> +  return __builtin_aarch64_shsubv8qi (__a, __b);
>  }
>  
>  __extension__ extern __inline int16x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsub_s16 (int16x4_t __a, int16x4_t __b)
>  {
> -  return (int16x4_t) __builtin_aarch64_shsubv4hi (__a, __b);
> +  return __builtin_aarch64_shsubv4hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsub_s32 (int32x2_t __a, int32x2_t __b)
>  {
> -  return (int32x2_t) __builtin_aarch64_shsubv2si (__a, __b);
> +  return __builtin_aarch64_shsubv2si (__a, __b);
>  }
>  
>  __extension__ extern __inline uint8x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsub_u8 (uint8x8_t __a, uint8x8_t __b)
>  {
> -  return (uint8x8_t) __builtin_aarch64_uhsubv8qi ((int8x8_t) __a,
> -						  (int8x8_t) __b);
> +  return __builtin_aarch64_uhsubv8qi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsub_u16 (uint16x4_t __a, uint16x4_t __b)
>  {
> -  return (uint16x4_t) __builtin_aarch64_uhsubv4hi ((int16x4_t) __a,
> -						   (int16x4_t) __b);
> +  return __builtin_aarch64_uhsubv4hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsub_u32 (uint32x2_t __a, uint32x2_t __b)
>  {
> -  return (uint32x2_t) __builtin_aarch64_uhsubv2si ((int32x2_t) __a,
> -						   (int32x2_t) __b);
> +  return __builtin_aarch64_uhsubv2si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int8x16_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsubq_s8 (int8x16_t __a, int8x16_t __b)
>  {
> -  return (int8x16_t) __builtin_aarch64_shsubv16qi (__a, __b);
> +  return __builtin_aarch64_shsubv16qi (__a, __b);
>  }
>  
>  __extension__ extern __inline int16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsubq_s16 (int16x8_t __a, int16x8_t __b)
>  {
> -  return (int16x8_t) __builtin_aarch64_shsubv8hi (__a, __b);
> +  return __builtin_aarch64_shsubv8hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsubq_s32 (int32x4_t __a, int32x4_t __b)
>  {
> -  return (int32x4_t) __builtin_aarch64_shsubv4si (__a, __b);
> +  return __builtin_aarch64_shsubv4si (__a, __b);
>  }
>  
>  __extension__ extern __inline uint8x16_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsubq_u8 (uint8x16_t __a, uint8x16_t __b)
>  {
> -  return (uint8x16_t) __builtin_aarch64_uhsubv16qi ((int8x16_t) __a,
> -						    (int8x16_t) __b);
> +  return __builtin_aarch64_uhsubv16qi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsubq_u16 (uint16x8_t __a, uint16x8_t __b)
>  {
> -  return (uint16x8_t) __builtin_aarch64_uhsubv8hi ((int16x8_t) __a,
> -						   (int16x8_t) __b);
> +  return __builtin_aarch64_uhsubv8hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vhsubq_u32 (uint32x4_t __a, uint32x4_t __b)
>  {
> -  return (uint32x4_t) __builtin_aarch64_uhsubv4si ((int32x4_t) __a,
> -						   (int32x4_t) __b);
> +  return __builtin_aarch64_uhsubv4si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int8x8_t


More information about the Gcc-patches mailing list