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 [R]ADDHN[2] Neon intrinsics
Date: Thu, 11 Nov 2021 10:31:04 +0000	[thread overview]
Message-ID: <mpta6ibrnkn.fsf@arm.com> (raw)
In-Reply-To: <DB9PR08MB695957AE0E64364748045B02EB949@DB9PR08MB6959.eurprd08.prod.outlook.com> (Jonathan Wright's message of "Thu, 11 Nov 2021 10:25:40 +0000")

Jonathan Wright <Jonathan.Wright@arm.com> writes:
> Hi,
>
> This patch declares unsigned type-qualified builtins and uses them to
> implement (rounding) halving-narrowing-add 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: Declare unsigned
>         builtins for [r]addhn[2].
>         * config/aarch64/arm_neon.h (vaddhn_s16): Remove unnecessary
>         cast.
>         (vaddhn_s32): Likewise.
>         (vaddhn_s64): Likewise.
>         (vaddhn_u16): Use type-qualified builtin and remove casts.
>         (vaddhn_u32): Likewise.
>         (vaddhn_u64): Likewise.
>         (vraddhn_s16): Remove unnecessary cast.
>         (vraddhn_s32): Likewise.
>         (vraddhn_s64): Likewise.
>         (vraddhn_u16): Use type-qualified builtin and remove casts.
>         (vraddhn_u32): Likewise.
>         (vraddhn_u64): Likewise.
>         (vaddhn_high_s16): Remove unnecessary cast.
>         (vaddhn_high_s32): Likewise.
>         (vaddhn_high_s64): Likewise.
>         (vaddhn_high_u16): Use type-qualified builtin and remove
>         casts.
>         (vaddhn_high_u32): Likewise.
>         (vaddhn_high_u64): Likewise.
>         (vraddhn_high_s16): Remove unnecessary cast.
>         (vraddhn_high_s32): Likewise.
>         (vraddhn_high_s64): Likewise.
>         (vraddhn_high_u16): Use type-qualified builtin and remove
>         casts.
>         (vraddhn_high_u32): Likewise.
>         (vraddhn_high_u64): Likewise.

OK, thanks.

Richard

> diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def b/gcc/config/aarch64/aarch64-simd-builtins.def
> index af04b732227439dcaaa2f3751097050d988eb729..6372da80be33c40cb27e5811bfb4f4f672f28a35 100644
> --- a/gcc/config/aarch64/aarch64-simd-builtins.def
> +++ b/gcc/config/aarch64/aarch64-simd-builtins.def
> @@ -220,13 +220,17 @@
>  
>    /* Implemented by aarch64_<sur><addsub>hn<mode>.  */
>    BUILTIN_VQN (BINOP, addhn, 0, NONE)
> +  BUILTIN_VQN (BINOPU, addhn, 0, NONE)
>    BUILTIN_VQN (BINOP, subhn, 0, NONE)
>    BUILTIN_VQN (BINOP, raddhn, 0, NONE)
> +  BUILTIN_VQN (BINOPU, raddhn, 0, NONE)
>    BUILTIN_VQN (BINOP, rsubhn, 0, NONE)
>    /* Implemented by aarch64_<sur><addsub>hn2<mode>.  */
>    BUILTIN_VQN (TERNOP, addhn2, 0, NONE)
> +  BUILTIN_VQN (TERNOPU, addhn2, 0, NONE)
>    BUILTIN_VQN (TERNOP, subhn2, 0, NONE)
>    BUILTIN_VQN (TERNOP, raddhn2, 0, NONE)
> +  BUILTIN_VQN (TERNOPU, raddhn2, 0, NONE)
>    BUILTIN_VQN (TERNOP, rsubhn2, 0, NONE)
>  
>    /* Implemented by aarch64_<us>xtl<mode>.  */
> diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h
> index b2781f680d142b848f622d2f4965b42985885502..cb481542ba0d6ffb7cc8ffe7c1a098930fc5e746 100644
> --- a/gcc/config/aarch64/arm_neon.h
> +++ b/gcc/config/aarch64/arm_neon.h
> @@ -713,186 +713,168 @@ __extension__ extern __inline int8x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_s16 (int16x8_t __a, int16x8_t __b)
>  {
> -  return (int8x8_t) __builtin_aarch64_addhnv8hi (__a, __b);
> +  return __builtin_aarch64_addhnv8hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int16x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_s32 (int32x4_t __a, int32x4_t __b)
>  {
> -  return (int16x4_t) __builtin_aarch64_addhnv4si (__a, __b);
> +  return __builtin_aarch64_addhnv4si (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_s64 (int64x2_t __a, int64x2_t __b)
>  {
> -  return (int32x2_t) __builtin_aarch64_addhnv2di (__a, __b);
> +  return __builtin_aarch64_addhnv2di (__a, __b);
>  }
>  
>  __extension__ extern __inline uint8x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_u16 (uint16x8_t __a, uint16x8_t __b)
>  {
> -  return (uint8x8_t) __builtin_aarch64_addhnv8hi ((int16x8_t) __a,
> -						  (int16x8_t) __b);
> +  return __builtin_aarch64_addhnv8hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_u32 (uint32x4_t __a, uint32x4_t __b)
>  {
> -  return (uint16x4_t) __builtin_aarch64_addhnv4si ((int32x4_t) __a,
> -						   (int32x4_t) __b);
> +  return __builtin_aarch64_addhnv4si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_u64 (uint64x2_t __a, uint64x2_t __b)
>  {
> -  return (uint32x2_t) __builtin_aarch64_addhnv2di ((int64x2_t) __a,
> -						   (int64x2_t) __b);
> +  return __builtin_aarch64_addhnv2di_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int8x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_s16 (int16x8_t __a, int16x8_t __b)
>  {
> -  return (int8x8_t) __builtin_aarch64_raddhnv8hi (__a, __b);
> +  return __builtin_aarch64_raddhnv8hi (__a, __b);
>  }
>  
>  __extension__ extern __inline int16x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_s32 (int32x4_t __a, int32x4_t __b)
>  {
> -  return (int16x4_t) __builtin_aarch64_raddhnv4si (__a, __b);
> +  return __builtin_aarch64_raddhnv4si (__a, __b);
>  }
>  
>  __extension__ extern __inline int32x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_s64 (int64x2_t __a, int64x2_t __b)
>  {
> -  return (int32x2_t) __builtin_aarch64_raddhnv2di (__a, __b);
> +  return __builtin_aarch64_raddhnv2di (__a, __b);
>  }
>  
>  __extension__ extern __inline uint8x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_u16 (uint16x8_t __a, uint16x8_t __b)
>  {
> -  return (uint8x8_t) __builtin_aarch64_raddhnv8hi ((int16x8_t) __a,
> -						   (int16x8_t) __b);
> +  return __builtin_aarch64_raddhnv8hi_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint16x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_u32 (uint32x4_t __a, uint32x4_t __b)
>  {
> -  return (uint16x4_t) __builtin_aarch64_raddhnv4si ((int32x4_t) __a,
> -						    (int32x4_t) __b);
> +  return __builtin_aarch64_raddhnv4si_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline uint32x2_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_u64 (uint64x2_t __a, uint64x2_t __b)
>  {
> -  return (uint32x2_t) __builtin_aarch64_raddhnv2di ((int64x2_t) __a,
> -						    (int64x2_t) __b);
> +  return __builtin_aarch64_raddhnv2di_uuu (__a, __b);
>  }
>  
>  __extension__ extern __inline int8x16_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_high_s16 (int8x8_t __a, int16x8_t __b, int16x8_t __c)
>  {
> -  return (int8x16_t) __builtin_aarch64_addhn2v8hi (__a, __b, __c);
> +  return __builtin_aarch64_addhn2v8hi (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline int16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_high_s32 (int16x4_t __a, int32x4_t __b, int32x4_t __c)
>  {
> -  return (int16x8_t) __builtin_aarch64_addhn2v4si (__a, __b, __c);
> +  return __builtin_aarch64_addhn2v4si (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline int32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_high_s64 (int32x2_t __a, int64x2_t __b, int64x2_t __c)
>  {
> -  return (int32x4_t) __builtin_aarch64_addhn2v2di (__a, __b, __c);
> +  return __builtin_aarch64_addhn2v2di (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline uint8x16_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_high_u16 (uint8x8_t __a, uint16x8_t __b, uint16x8_t __c)
>  {
> -  return (uint8x16_t) __builtin_aarch64_addhn2v8hi ((int8x8_t) __a,
> -						    (int16x8_t) __b,
> -						    (int16x8_t) __c);
> +  return __builtin_aarch64_addhn2v8hi_uuuu (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline uint16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_high_u32 (uint16x4_t __a, uint32x4_t __b, uint32x4_t __c)
>  {
> -  return (uint16x8_t) __builtin_aarch64_addhn2v4si ((int16x4_t) __a,
> -						    (int32x4_t) __b,
> -						    (int32x4_t) __c);
> +  return __builtin_aarch64_addhn2v4si_uuuu (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline uint32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vaddhn_high_u64 (uint32x2_t __a, uint64x2_t __b, uint64x2_t __c)
>  {
> -  return (uint32x4_t) __builtin_aarch64_addhn2v2di ((int32x2_t) __a,
> -						    (int64x2_t) __b,
> -						    (int64x2_t) __c);
> +  return __builtin_aarch64_addhn2v2di_uuuu (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline int8x16_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_high_s16 (int8x8_t __a, int16x8_t __b, int16x8_t __c)
>  {
> -  return (int8x16_t) __builtin_aarch64_raddhn2v8hi (__a, __b, __c);
> +  return __builtin_aarch64_raddhn2v8hi (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline int16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_high_s32 (int16x4_t __a, int32x4_t __b, int32x4_t __c)
>  {
> -  return (int16x8_t) __builtin_aarch64_raddhn2v4si (__a, __b, __c);
> +  return __builtin_aarch64_raddhn2v4si (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline int32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_high_s64 (int32x2_t __a, int64x2_t __b, int64x2_t __c)
>  {
> -  return (int32x4_t) __builtin_aarch64_raddhn2v2di (__a, __b, __c);
> +  return __builtin_aarch64_raddhn2v2di (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline uint8x16_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_high_u16 (uint8x8_t __a, uint16x8_t __b, uint16x8_t __c)
>  {
> -  return (uint8x16_t) __builtin_aarch64_raddhn2v8hi ((int8x8_t) __a,
> -						     (int16x8_t) __b,
> -						     (int16x8_t) __c);
> +  return __builtin_aarch64_raddhn2v8hi_uuuu (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline uint16x8_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_high_u32 (uint16x4_t __a, uint32x4_t __b, uint32x4_t __c)
>  {
> -  return (uint16x8_t) __builtin_aarch64_raddhn2v4si ((int16x4_t) __a,
> -						     (int32x4_t) __b,
> -						     (int32x4_t) __c);
> +  return __builtin_aarch64_raddhn2v4si_uuuu (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline uint32x4_t
>  __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
>  vraddhn_high_u64 (uint32x2_t __a, uint64x2_t __b, uint64x2_t __c)
>  {
> -  return (uint32x4_t) __builtin_aarch64_raddhn2v2di ((int32x2_t) __a,
> -						     (int64x2_t) __b,
> -						     (int64x2_t) __c);
> +  return __builtin_aarch64_raddhn2v2di_uuuu (__a, __b, __c);
>  }
>  
>  __extension__ extern __inline float32x2_t

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 10:25 Jonathan Wright
2021-11-11 10:31 ` 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=mpta6ibrnkn.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).