From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Carl Love <cel@linux.ibm.com>
Cc: gcc-patches@gcc.gnu.org,
"bergner@linux.ibm.com" <bergner@linux.ibm.com>,
Segher Boessenkool <segher@kernel.crashing.org>,
David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH 4/13] rs6000, extend the current vec_{un,}signed{e,o} built-ins
Date: Tue, 14 May 2024 15:53:35 +0800 [thread overview]
Message-ID: <abcbbb68-05a2-5f32-9812-3fe510e99205@linux.ibm.com> (raw)
In-Reply-To: <0519d8a3-38aa-4039-ba02-f88f408eb23f@linux.ibm.com>
Hi,
on 2024/4/20 05:17, Carl Love wrote:
> rs6000, extend the current vec_{un,}signed{e,o} built-ins
>
> The built-ins __builtin_vsx_xvcvspsxds and __builtin_vsx_xvcvspuxds
> convert a vector of floats to signed/unsigned long long ints. Extend the
> existing vec_{un,}signed{e,o} built-ins to handle the argument
> vector of floats to return the even/odd signed/unsigned integers.
>
> Add testcases and update documentation.
>
> gcc/ChangeLog:
> * config/rs6000/rs6000-builtins.def (__builtin_vsx_xvcvspsxds_low,
> __builtin_vsx_xvcvspuxds_low): New built-in definitions.
> * config/rs6000/rs6000-overload.def (vec_signede, vec_signedo):
> Add new overloaded specifications.
> * config/rs6000/vsx.md (vsx_xvcvsp<su>xds_low): New define_expand.
> * doc/extend.texi (vec_signedo, vec_signede): Add documentation.
>
> gcc/testsuite/ChangeLog:
> * gcc.target/powerpc/builtins-3-runnable: New tests for the added
> overloaded built-ins.
This part is missing, there are no test case changes in this patch.
> ---
> gcc/config/rs6000/rs6000-builtins.def | 6 ++++++
> gcc/config/rs6000/rs6000-overload.def | 8 ++++++++
> gcc/config/rs6000/vsx.md | 23 +++++++++++++++++++++++
> gcc/doc/extend.texi | 13 +++++++++++++
> 4 files changed, 50 insertions(+)
>
> diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def
> index bf9a0ae22fc..5b7237a2327 100644
> --- a/gcc/config/rs6000/rs6000-builtins.def
> +++ b/gcc/config/rs6000/rs6000-builtins.def
> @@ -1709,9 +1709,15 @@
> const vsll __builtin_vsx_xvcvspsxds (vf);
> XVCVSPSXDS vsx_xvcvspsxds {}
>
> + const vsll __builtin_vsx_xvcvspsxds_low (vf);
> + XVCVSPSXDSO vsx_xvcvspsxds_low {}
> +
> const vsll __builtin_vsx_xvcvspuxds (vf);
> XVCVSPUXDS vsx_xvcvspuxds {}
This existing should return with type vull, ...
>
> + const vsll __builtin_vsx_xvcvspuxds_low (vf);
> + XVCVSPUXDSO vsx_xvcvspuxds_low {}
... so this copied one should be vull too.
As the existing instances for vec_signed and vec_unsigned are with
names like VEC_V{UN,}SIGNED{O,E}_V2DF, I prefer these are updated
with similar style, maybe something like:
VEC_V{UN,}SIGNED{E,O}_V4SF v{un,}signed{e,o}_v4sf
> const vsi __builtin_vsx_xvcvspuxws (vf);
> XVCVSPUXWS vsx_fixuns_truncv4sfv4si2 {}
> > diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def
> index 84bd9ae6554..68501c05289 100644
> --- a/gcc/config/rs6000/rs6000-overload.def
> +++ b/gcc/config/rs6000/rs6000-overload.def
> @@ -3307,10 +3307,14 @@
> [VEC_SIGNEDE, vec_signede, __builtin_vec_vsignede]
> vsi __builtin_vec_vsignede (vd);
> VEC_VSIGNEDE_V2DF
> + vsll __builtin_vec_vsignede (vf);
> + XVCVSPSXDS
>
> [VEC_SIGNEDO, vec_signedo, __builtin_vec_vsignedo]
> vsi __builtin_vec_vsignedo (vd);
> VEC_VSIGNEDO_V2DF
> + vsll __builtin_vec_vsignedo (vf);
> + XVCVSPSXDSO
>
> [VEC_SIGNEXTI, vec_signexti, __builtin_vec_signexti]
> vsi __builtin_vec_signexti (vsc);
> @@ -4433,10 +4437,14 @@
> [VEC_UNSIGNEDE, vec_unsignede, __builtin_vec_vunsignede]
> vui __builtin_vec_vunsignede (vd);
> VEC_VUNSIGNEDE_V2DF
> + vull __builtin_vec_vunsignede (vf);
> + XVCVSPUXDS
>
> [VEC_UNSIGNEDO, vec_unsignedo, __builtin_vec_vunsignedo]
> vui __builtin_vec_vunsignedo (vd);
> VEC_VUNSIGNEDO_V2DF
> + vull __builtin_vec_vunsignedo (vf);
> + XVCVSPUXDSO
>
As above, the name can be tweaked.
> [VEC_VEE, vec_extract_exp, __builtin_vec_extract_exp]
> vui __builtin_vec_extract_exp (vf);
> diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
> index f135fa079bd..3d39ae7995f 100644
> --- a/gcc/config/rs6000/vsx.md
> +++ b/gcc/config/rs6000/vsx.md
> @@ -2704,6 +2704,29 @@
> DONE;
> })
>
> +;; Convert low vector elements of 32-bit floating point numbers to vector of
> +;; 64-bit signed/unsigned integers.
> +(define_expand "vsx_xvcvsp<su>xds_low"
> + [(match_operand:V2DI 0 "vsx_register_operand")
> + (match_operand:V4SF 1 "vsx_register_operand")
> + (any_fix (pc))]
> + "VECTOR_UNIT_VSX_P (V2DFmode)"
> +{
> + /* Shift left one word to put even word in correct location */
> + rtx rtx_tmp;
> + rtx rtx_val = GEN_INT (4);
> + rtx_tmp = gen_reg_rtx (V4SFmode);
> + emit_insn (gen_altivec_vsldoi_v4sf (rtx_tmp, operands[1], operands[1],
> + rtx_val));
> +
I think this shift is only needed for LE, see the existing handlings on
float/signed int to double conversions, like:
(define_expand "doublee<mode>2"
(define_expand "doubleo<mode>2"
> + if (BYTES_BIG_ENDIAN)
> + emit_insn (gen_vsx_xvcvsp<su>xds_be (operands[0], rtx_tmp));
> + else
> + emit_insn (gen_vsx_xvcvsp<su>xds_le (operands[0], rtx_tmp));
> +
> + DONE;
> +})
> +
> ;; Generate float2 double
> ;; convert two double to float
> (define_expand "float2_v2df"
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index 7b54a241a7b..64a43b55e2d 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -22552,6 +22552,19 @@ can use @var{vector long} instead of @var{vector long long},
> @var{vector bool long} instead of @var{vector bool long long}, and
> @var{vector unsigned long} instead of @var{vector unsigned long long}.
>
> +@smallexample
> +vector signed signed long long vec_signedo (vector float);
> +vector signed signed long long vec_signede (vector float);
> +vector unsigned signed long long vec_signedo (vector float);
> +vector unsigned signed long long vec_signede (vector float);
> +@end smallexample
> +
> +The overloaded built-ins @code{vec_signedo} and @code{vec_signede} convert the
> +even/odd input vector elements to signed/unsigned long long integer values in
> +addition to the supported arguments and return types documented in the PVIPR.
> +Negative input values are returned as zero for the unsigned long long return
> +values.
These functions are placed in stanza [vsx] instead of [power8-vector], so it should
be in the section "PowerPC AltiVec Built-in Functions Available on ISA 2.06".
As mentioned in the replies to other patches, since it's an extension from the
existing PVIPR bifs and there is nothing special from them, I prefer to just mention
them but omit the description on them.
BR,
Kewen
> +
> Only functions excluded from the PVIPR are listed here.
>
> @smallexample
next prev parent reply other threads:[~2024-05-14 7:53 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 21:04 [PATCH 0/13] rs6000, built-in cleanup patch series Carl Love
2024-04-19 21:16 ` [PATCH 1/13] rs6000, Remove __builtin_vsx_cmple* builtins Carl Love
2024-05-13 6:28 ` Kewen.Lin
2024-04-19 21:17 ` [PATCH 2/13] rs6000, Remove __builtin_vsx_xvcvspsxws built-in Carl Love
2024-05-14 8:43 ` Kewen.Lin
2024-05-24 20:18 ` Carl Love
2024-05-27 1:43 ` Kewen.Lin
2024-04-19 21:17 ` [PATCH 3/13] rs6000, fix error in unsigned vector float to unsigned int built-in definitions Carl Love
2024-05-14 7:00 ` Kewen.Lin
2024-05-24 20:19 ` Carl Love
2024-04-19 21:17 ` [PATCH 4/13] rs6000, extend the current vec_{un,}signed{e,o} built-ins Carl Love
2024-05-14 7:53 ` Kewen.Lin [this message]
2024-05-17 20:20 ` Carl Love
2024-05-20 1:10 ` Kewen.Lin
2024-05-24 20:19 ` Carl Love
2024-04-19 21:17 ` [PATCH 5/13] rs6000, remove duplicated built-ins of vecmergl and vec_mergeh Carl Love
2024-05-14 2:06 ` Kewen.Lin
2024-04-19 21:17 ` [PATCH 6/13] rs6000, add overloaded vec_sel with int128 arguments Carl Love
2024-05-14 2:54 ` Kewen.Lin
2024-05-22 0:13 ` Carl Love
2024-05-22 3:05 ` Kewen.Lin
2024-05-24 20:19 ` Carl Love
2024-04-19 21:18 ` [PATCH 7/13] rs6000, remove the vec_xxsel built-ins, they are duplicates Carl Love
2024-05-14 2:55 ` Kewen.Lin
2024-05-24 20:19 ` Carl Love
2024-04-19 21:18 ` [PATCH 8/13] rs6000, remove __builtin_vsx_vperm_* built-ins Carl Love
2024-05-14 2:59 ` Kewen.Lin
2024-05-24 20:20 ` Carl Love
2024-04-19 21:18 ` [PATCH 9/13] rs6000, remove __builtin_vsx_xvnegdp and __builtin_vsx_xvnegsp built-ins Carl Love
2024-05-14 3:01 ` Kewen.Lin
2024-04-19 21:18 ` [PATCH 10/13] rs6000, extend vec_xxpermdi built-in for __int128 args Carl Love
2024-05-14 5:14 ` Kewen.Lin
2024-05-24 20:20 ` Carl Love
2024-04-19 21:18 ` [PATCH 11/13] rs6000, remove __builtin_vsx_xvcmpeqsp_p built-in Carl Love
2024-05-14 5:26 ` Kewen.Lin
2024-05-24 20:20 ` Carl Love
2024-04-19 21:18 ` [PATCH 12/13] rs6000, remove __builtin_vsx_xvcmpeqsp built-in Carl Love
2024-05-14 5:37 ` Kewen.Lin
2024-05-23 18:21 ` Carl Love
2024-05-24 10:43 ` Kewen.Lin
2024-05-24 15:19 ` Carl Love
2024-04-19 21:18 ` [PATCH 13/13] rs6000, remove vector set and vector init built-ins Carl Love
2024-05-14 5:44 ` Kewen.Lin
2024-05-23 0:29 ` Carl Love
2024-05-23 2:27 ` Kewen.Lin
2024-05-10 15:15 ` [PING} Re: [PATCH 0/13] rs6000, built-in cleanup patch series Carl Love
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=abcbbb68-05a2-5f32-9812-3fe510e99205@linux.ibm.com \
--to=linkw@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=cel@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.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).