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 3/13] rs6000, fix error in unsigned vector float to unsigned int built-in definitions
Date: Tue, 14 May 2024 15:00:18 +0800 [thread overview]
Message-ID: <d7f2d02a-a422-04e4-baa5-cb7302abca53@linux.ibm.com> (raw)
In-Reply-To: <b60c4f2b-8216-459a-b8f6-89045ccdcd80@linux.ibm.com>
Hi,
on 2024/4/20 05:17, Carl Love wrote:
> rs6000, fix error in unsigned vector float to unsigned int built-in definitions
>
> The built-ins __builtin_vsx_vunsigned_v2df and__builtin_vsx_vunsigned_v4sf
> are supposed to take a vector of floats and return a vector of unsigned
> long long ints. The definitions are using the signed version of the
Sorry for nitpicking, here __builtin_vsx_vunsigned_v2df takes vector of doubles
and returns vector of unsigned long long ints while __builtin_vsx_vunsigned_v4sf
takes vector of floats and returns vector of unsigned ints.
> instructions not the unsigned version of the instruction. The results
> should also be unsigned. The builtins are used by the overloaded
> vec_unsigned builtin which has an unsigned result.
>
> Similarly the built-ins __builtin_vsx_vunsignede_v2df and
> __builtin_vsx_vunsignedo_v2df are supposed to retun an unsigned result.
Nit: s/retun/return/
> If the floating point argument is negative, the unsigned result is zero.
> The built-ins are used in the overloaded built-in vec_unsignede and
> vec_unsignedo respectively.
>
> Add a test cases for a negative floating point arguments for each of the
> above built-ins.
>
> gcc/ChangeLog:
> * config/rs6000/rs6000-builtins.def (__builtin_vsx_vunsigned_v2df,
> __builtin_vsx_vunsigned_v4sf, __builtin_vsx_vunsignede_v2df,
> __builtin_vsx_vunsignedo_v2df): Change the result type to unsigned.
>
> gcc/testsuite/ChangeLog:
> * gcc.target/powerpc/builtins-3-runnable.c: Add tests for
> vec_unsignede and vec_unsignedo with negative arguments.
> ---
> gcc/config/rs6000/rs6000-builtins.def | 12 +++++-----
> .../gcc.target/powerpc/builtins-3-runnable.c | 23 ++++++++++++++++---
> 2 files changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def
> index c6d2ea1bc39..bf9a0ae22fc 100644
> --- a/gcc/config/rs6000/rs6000-builtins.def
> +++ b/gcc/config/rs6000/rs6000-builtins.def
> @@ -1580,16 +1580,16 @@
> const vsi __builtin_vsx_vsignedo_v2df (vd);
> VEC_VSIGNEDO_V2DF vsignedo_v2df {}
>
> - const vsll __builtin_vsx_vunsigned_v2df (vd);
> - VEC_VUNSIGNED_V2DF vsx_xvcvdpsxds {}
> + const vull __builtin_vsx_vunsigned_v2df (vd);
> + VEC_VUNSIGNED_V2DF vsx_xvcvdpuxds {}
>
> - const vsi __builtin_vsx_vunsigned_v4sf (vf);
> - VEC_VUNSIGNED_V4SF vsx_xvcvspsxws {}
> + const vui __builtin_vsx_vunsigned_v4sf (vf);
> + VEC_VUNSIGNED_V4SF vsx_xvcvspuxws {}
>
> - const vsi __builtin_vsx_vunsignede_v2df (vd);
> + const vui __builtin_vsx_vunsignede_v2df (vd);
> VEC_VUNSIGNEDE_V2DF vunsignede_v2df {}
>
> - const vsi __builtin_vsx_vunsignedo_v2df (vd);
> + const vui __builtin_vsx_vunsignedo_v2df (vd);
> VEC_VUNSIGNEDO_V2DF vunsignedo_v2df {}
>
> const vf __builtin_vsx_xscvdpsp (double);
> diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c
> index 0231a1fd086..6d4fe84c8a1 100644
> --- a/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c
> +++ b/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c
> @@ -313,6 +313,15 @@ int main()
> test_unsigned_int_result (ALL, vec_uns_int_result,
> vec_uns_int_expected);
>
> + /* Convert single precision float to unsigned int. Negative
> + arguments
> + */
> + vec_flt0 = (vector float){-14.930, -834.49, -3.3, -5.4};
> + vec_uns_int_expected = (vector unsigned int){0, 0, 0, 0};
> + vec_uns_int_result = vec_unsigned (vec_flt0);
> + test_unsigned_int_result (ALL, vec_uns_int_result,
> + vec_uns_int_expected);
> +
> /* Convert double precision float to long long unsigned int */
> vec_dble0 = (vector double){124.930, 8134.49};
> vec_ll_uns_int_expected = (vector long long unsigned int){124, 8134};
> @@ -321,9 +330,9 @@ int main()
> vec_ll_uns_int_expected);
Nit: Similar coverage on negative for vector double can be added here.
BR,
Kewen
>
> /* Convert double precision vector float to vector unsigned int,
> - even words */
> - vec_dble0 = (vector double){3124.930, 8234.49};
> - vec_uns_int_expected = (vector unsigned int){3124, 0, 8234, 0};
> + even words. Negative arguments */
> + vec_dble0 = (vector double){-124.930, -234.49};
> + vec_uns_int_expected = (vector unsigned int){0, 0, 0, 0};
> vec_uns_int_result = vec_unsignede (vec_dble0);
> test_unsigned_int_result (EVEN, vec_uns_int_result,
> vec_uns_int_expected);
> @@ -335,5 +344,13 @@ int main()
> vec_uns_int_result = vec_unsignedo (vec_dble0);
> test_unsigned_int_result (ODD, vec_uns_int_result,
> vec_uns_int_expected);
> +
> + /* Convert double precision vector float to vector unsigned int,
> + odd words. Negative arguments. */
> + vec_dble0 = (vector double){-924.930, -1234.49};
> + vec_uns_int_expected = (vector unsigned int){0, 0, 0, 0};
> + vec_uns_int_result = vec_unsignedo (vec_dble0);
> + test_unsigned_int_result (ODD, vec_uns_int_result,
> + vec_uns_int_expected);
> }
>
next prev parent reply other threads:[~2024-05-14 7:00 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 [this message]
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
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=d7f2d02a-a422-04e4-baa5-cb7302abca53@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).