public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Jonathan Wright <Jonathan.Wright@arm.com>
Cc: "gcc-patches\@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
Subject: Re: [PATCH] aarch64: Use type-qualified builtins for USUB[LW][2] Neon intrinsics
Date: Thu, 11 Nov 2021 10:26:44 +0000	[thread overview]
Message-ID: <mptpmr7rnrv.fsf@arm.com> (raw)
In-Reply-To: <DB9PR08MB69591EA055BC25FA003A9ED8EB949@DB9PR08MB6959.eurprd08.prod.outlook.com> (Jonathan Wright's message of "Thu, 11 Nov 2021 10:19:44 +0000")

Jonathan Wright <Jonathan.Wright@arm.com> writes:
> Hi,
>
> This patch declares unsigned type-qualified builtins and uses them to
> implement widening-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 usub[lw][2] builtins.
>         * config/aarch64/arm_neon.h (vsubl_s8): Remove unnecessary
>         cast.
>         (vsubl_s16): Likewise.
>         (vsubl_s32): Likewise.
>         (vsubl_u8): Use type-qualified builtin and remove casts.
>         (vsubl_u16): Likewise.
>         (vsubl_u32): Likewise.
>         (vsubl_high_s8): Remove unnecessary cast.
>         (vsubl_high_s16): Likewise.
>         (vsubl_high_s32): Likewise.
>         (vsubl_high_u8): Use type-qualified builtin and remove casts.
>         (vsubl_high_u16): Likewise.
>         (vsubl_high_u32): Likewise.
>         (vsubw_s8): Remove unnecessary casts.
>         (vsubw_s16): Likewise.
>         (vsubw_s32): Likewise.
>         (vsubw_u8): Use type-qualified builtin and remove casts.
>         (vsubw_u16): Likewise.
>         (vsubw_u32): Likewise.
>         (vsubw_high_s8): Remove unnecessary cast.
>         (vsubw_high_s16): Likewise.
>         (vsubw_high_s32): Likewise.
>         (vsubw_high_u8): Use type-qualified builtin and remove casts.
>         (vsubw_high_u16): Likewise.
>         (vsubw_high_u32): Likewise.

OK, thanks.

Richard

>
> diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def b/gcc/config/aarch64/aarch64-simd-builtins.def
> index ccd194978f948201698aec16d74baa82c187cad4..be06a80cea379b8b78c798dbec47fb95eec68db1 100644
> --- a/gcc/config/aarch64/aarch64-simd-builtins.def
> +++ b/gcc/config/aarch64/aarch64-simd-builtins.def
> @@ -160,21 +160,21 @@
>    BUILTIN_VQW (BINOP, saddl2, 0, NONE)
>    BUILTIN_VQW (BINOPU, uaddl2, 0, NONE)
>    BUILTIN_VQW (BINOP, ssubl2, 0, NONE)
> -  BUILTIN_VQW (BINOP, usubl2, 0, NONE)
> +  BUILTIN_VQW (BINOPU, usubl2, 0, NONE)
>    BUILTIN_VQW (BINOP, saddw2, 0, NONE)
>    BUILTIN_VQW (BINOPU, uaddw2, 0, NONE)
>    BUILTIN_VQW (BINOP, ssubw2, 0, NONE)
> -  BUILTIN_VQW (BINOP, usubw2, 0, NONE)
> +  BUILTIN_VQW (BINOPU, usubw2, 0, NONE)
>    /* Implemented by aarch64_<ANY_EXTEND:su><ADDSUB:optab>l<mode>.  */
>    BUILTIN_VD_BHSI (BINOP, saddl, 0, NONE)
>    BUILTIN_VD_BHSI (BINOPU, uaddl, 0, NONE)
>    BUILTIN_VD_BHSI (BINOP, ssubl, 0, NONE)
> -  BUILTIN_VD_BHSI (BINOP, usubl, 0, NONE)
> +  BUILTIN_VD_BHSI (BINOPU, usubl, 0, NONE)
>    /* Implemented by aarch64_<ANY_EXTEND:su><ADDSUB:optab>w<mode>.  */
>    BUILTIN_VD_BHSI (BINOP, saddw, 0, NONE)
>    BUILTIN_VD_BHSI (BINOPU, uaddw, 0, NONE)
>    BUILTIN_VD_BHSI (BINOP, ssubw, 0, NONE)
> -  BUILTIN_VD_BHSI (BINOP, usubw, 0, NONE)
> +  BUILTIN_VD_BHSI (BINOPU, usubw, 0, NONE)
>    /* Implemented by aarch64_<sur>h<addsub><mode>.  */
>    BUILTIN_VDQ_BHSI (BINOP, shadd, 0, NONE)
>    BUILTIN_VDQ_BHSI (BINOP, shsub, 0, NONE)
> diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h
> index a3d742f25a896f8e736a5fb01535d372cd4b20db..58b3dddb2c4ebf856de0e9cf0399e42d322beff9 100644
> --- a/gcc/config/aarch64/arm_neon.h
> +++ b/gcc/config/aarch64/arm_neon.h
> @@ -1765,180 +1765,168 @@ __extension__ extern __inline int16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_s8 (int8x8_t __a, int8x8_t __b)
>  {
> -  return (int16x8_t) __builtin_aarch64_ssublv8qi (__a, __b);
> +  return __builtin_aarch64_ssublv8qi (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_s16 (int16x4_t __a, int16x4_t __b)
>  {
> -  return (int32x4_t) __builtin_aarch64_ssublv4hi (__a, __b);
> +  return __builtin_aarch64_ssublv4hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_s32 (int32x2_t __a, int32x2_t __b)
>  {
> -  return (int64x2_t) __builtin_aarch64_ssublv2si (__a, __b);
> +  return __builtin_aarch64_ssublv2si (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_u8 (uint8x8_t __a, uint8x8_t __b)
>  {
> -  return (uint16x8_t) __builtin_aarch64_usublv8qi ((int8x8_t) __a,
> -						   (int8x8_t) __b);
> +  return __builtin_aarch64_usublv8qi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_u16 (uint16x4_t __a, uint16x4_t __b)
>  {
> -  return (uint32x4_t) __builtin_aarch64_usublv4hi ((int16x4_t) __a,
> -						   (int16x4_t) __b);
> +  return __builtin_aarch64_usublv4hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_u32 (uint32x2_t __a, uint32x2_t __b)
>  {
> -  return (uint64x2_t) __builtin_aarch64_usublv2si ((int32x2_t) __a,
> -						   (int32x2_t) __b);
> +  return __builtin_aarch64_usublv2si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_high_s8 (int8x16_t __a, int8x16_t __b)
>  {
> -  return (int16x8_t) __builtin_aarch64_ssubl2v16qi (__a, __b);
> +  return __builtin_aarch64_ssubl2v16qi (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_high_s16 (int16x8_t __a, int16x8_t __b)
>  {
> -  return (int32x4_t) __builtin_aarch64_ssubl2v8hi (__a, __b);
> +  return __builtin_aarch64_ssubl2v8hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_high_s32 (int32x4_t __a, int32x4_t __b)
>  {
> -  return (int64x2_t) __builtin_aarch64_ssubl2v4si (__a, __b);
> +  return __builtin_aarch64_ssubl2v4si (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_high_u8 (uint8x16_t __a, uint8x16_t __b)
>  {
> -  return (uint16x8_t) __builtin_aarch64_usubl2v16qi ((int8x16_t) __a,
> -						     (int8x16_t) __b);
> +  return __builtin_aarch64_usubl2v16qi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_high_u16 (uint16x8_t __a, uint16x8_t __b)
>  {
> -  return (uint32x4_t) __builtin_aarch64_usubl2v8hi ((int16x8_t) __a,
> -						    (int16x8_t) __b);
> +  return __builtin_aarch64_usubl2v8hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubl_high_u32 (uint32x4_t __a, uint32x4_t __b)
>  {
> -  return (uint64x2_t) __builtin_aarch64_usubl2v4si ((int32x4_t) __a,
> -						    (int32x4_t) __b);
> +  return __builtin_aarch64_usubl2v4si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_s8 (int16x8_t __a, int8x8_t __b)
>  {
> -  return (int16x8_t) __builtin_aarch64_ssubwv8qi (__a, __b);
> +  return __builtin_aarch64_ssubwv8qi (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_s16 (int32x4_t __a, int16x4_t __b)
>  {
> -  return (int32x4_t) __builtin_aarch64_ssubwv4hi (__a, __b);
> +  return __builtin_aarch64_ssubwv4hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_s32 (int64x2_t __a, int32x2_t __b)
>  {
> -  return (int64x2_t) __builtin_aarch64_ssubwv2si (__a, __b);
> +  return __builtin_aarch64_ssubwv2si (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_u8 (uint16x8_t __a, uint8x8_t __b)
>  {
> -  return (uint16x8_t) __builtin_aarch64_usubwv8qi ((int16x8_t) __a,
> -						   (int8x8_t) __b);
> +  return __builtin_aarch64_usubwv8qi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_u16 (uint32x4_t __a, uint16x4_t __b)
>  {
> -  return (uint32x4_t) __builtin_aarch64_usubwv4hi ((int32x4_t) __a,
> -						   (int16x4_t) __b);
> +  return __builtin_aarch64_usubwv4hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_u32 (uint64x2_t __a, uint32x2_t __b)
>  {
> -  return (uint64x2_t) __builtin_aarch64_usubwv2si ((int64x2_t) __a,
> -						   (int32x2_t) __b);
> +  return __builtin_aarch64_usubwv2si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_high_s8 (int16x8_t __a, int8x16_t __b)
>  {
> -  return (int16x8_t) __builtin_aarch64_ssubw2v16qi (__a, __b);
> +  return __builtin_aarch64_ssubw2v16qi (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_high_s16 (int32x4_t __a, int16x8_t __b)
>  {
> -  return (int32x4_t) __builtin_aarch64_ssubw2v8hi (__a, __b);
> +  return __builtin_aarch64_ssubw2v8hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_high_s32 (int64x2_t __a, int32x4_t __b)
>  {
> -  return (int64x2_t) __builtin_aarch64_ssubw2v4si (__a, __b);
> +  return __builtin_aarch64_ssubw2v4si (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_high_u8 (uint16x8_t __a, uint8x16_t __b)
>  {
> -  return (uint16x8_t) __builtin_aarch64_usubw2v16qi ((int16x8_t) __a,
> -						     (int8x16_t) __b);
> +  return __builtin_aarch64_usubw2v16qi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_high_u16 (uint32x4_t __a, uint16x8_t __b)
>  {
> -  return (uint32x4_t) __builtin_aarch64_usubw2v8hi ((int32x4_t) __a,
> -						    (int16x8_t) __b);
> +  return __builtin_aarch64_usubw2v8hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint64x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vsubw_high_u32 (uint64x2_t __a, uint32x4_t __b)
>  {
> -  return (uint64x2_t) __builtin_aarch64_usubw2v4si ((int64x2_t) __a,
> -						    (int32x4_t) __b);
> +  return __builtin_aarch64_usubw2v4si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int8x8_t

      reply	other threads:[~2021-11-11 10:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 10:19 Jonathan Wright
2021-11-11 10:26 ` Richard Sandiford [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mptpmr7rnrv.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=Jonathan.Wright@arm.com \
    --cc=Kyrylo.Tkachov@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).