From: HAO CHEN GUI <guihaoc@linux.ibm.com>
To: "Kewen.Lin" <linkw@linux.ibm.com>
Cc: Bill Schmidt <wschmidt@linux.ibm.com>,
gcc-patches <gcc-patches@gcc.gnu.org>,
Segher Boessenkool <segher@kernel.crashing.org>
Subject: Re: [PATCH, rs6000] Disable gimple fold for float or double vec_minmax when fast-math is not set
Date: Wed, 25 Aug 2021 16:44:53 +0800 [thread overview]
Message-ID: <d555d244-5251-4550-c849-ad8e0596e8cb@linux.ibm.com> (raw)
In-Reply-To: <97d870cd-353b-c4a6-ab95-d0e9dcef55bb@linux.ibm.com>
On 25/8/2021 下午 4:17, HAO CHEN GUI via Gcc-patches wrote:
> Hi Kewen,
>
> Thanks for your advice.
>
> On 25/8/2021 下午 3:50, Kewen.Lin wrote:
>> Hi Haochen,
>>
>> on 2021/8/25 下午3:06, HAO CHEN GUI via Gcc-patches wrote:
>>> Hi,
>>>
>>> I refined the patch according to Bill's advice. I pasted the
>>> ChangeLog and diff file here. If it doesn't work, please let me
>>> know. Thanks.
>>>
>>> 2021-08-25 Haochen Gui <guihaoc@linux.ibm.com>
>>>
>>> gcc/
>> IIUC, this patch is for PR93127, one line for PR is missing here.
> The patch does comes from the PR, but it doesn't work as the PR
> requires. So I am not sure if I should add the PR number.
>>
>>> * config/rs6000/rs6000-call.c (rs6000_gimple_fold_builtin):
>>> Modify the VSX_BUILTIN_XVMINDP, ALTIVEC_BUILTIN_VMINFP,
>>> VSX_BUILTIN_XVMAXDP, ALTIVEC_BUILTIN_VMAXFP expansions.
>>>
>>> gcc/testsuite/
>> Same, need a PR line.
>>
>>> * gcc.target/powerpc/vec-minmax-1.c: New test.
>>> * gcc.target/powerpc/vec-minmax-2.c: Likewise.
>>>
>> Maybe it's better to use pr93127-{1,2}.c for case names?
>>
>> ...
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.target/powerpc/vec-minmax-1.c
>>> @@ -0,0 +1,53 @@
>>> +/* { dg-do compile { target { powerpc64le-*-* } } } */
>> I guess this "powerpc64le" isn't intentional? The test case
>> has the macro to distinguish endianess, I assume we want this
>> to be compiled on BE? If so, we just put the line below instead?
> It should be tested on BE as well. I will replace it with
> 'powerpc*-*-* && lp64'.
It should be 'powerpc*-*-*'. Thanks again!
>>
>> /* { dg-do compile } */
>>
>> And it needs extra testing on BE as well. :)
>>
>> Thanks for fixing this!
>>
>> BR,
>> Kewen
>>
>>> +/* { dg-require-effective-target powerpc_p9vector_ok } */
>>> +/* { dg-options "-O2 -mdejagnu-cpu=power9" } */
>>> +/* { dg-final { scan-assembler-times {\mxvmaxdp\M} 1 } } */
>>> +/* { dg-final { scan-assembler-times {\mxvmaxsp\M} 1 } } */
>>> +/* { dg-final { scan-assembler-times {\mxvmindp\M} 1 } } */
>>> +/* { dg-final { scan-assembler-times {\mxvminsp\M} 1 } } */
>>> +
>>> +/* This test verifies that float or double vec_min/max are bound to
>>> + xv[min|max][d|s]p instructions when fast-math is not set. */
>>> +
>>> +
>>> +#include <altivec.h>
>>> +
>>> +#ifdef _BIG_ENDIAN
>>> + const int PREF_D = 0;
>>> +#else
>>> + const int PREF_D = 1;
>>> +#endif
>>> +
>>> +double vmaxd (double a, double b)
>>> +{
>>> + vector double va = vec_promote (a, PREF_D);
>>> + vector double vb = vec_promote (b, PREF_D);
>>> + return vec_extract (vec_max (va, vb), PREF_D);
>>> +}
>>> +
>>> +double vmind (double a, double b)
>>> +{
>>> + vector double va = vec_promote (a, PREF_D);
>>> + vector double vb = vec_promote (b, PREF_D);
>>> + return vec_extract (vec_min (va, vb), PREF_D);
>>> +}
>>> +
>>> +#ifdef _BIG_ENDIAN
>>> + const int PREF_F = 0;
>>> +#else
>>> + const int PREF_F = 3;
>>> +#endif
>>> +
>>> +float vmaxf (float a, float b)
>>> +{
>>> + vector float va = vec_promote (a, PREF_F);
>>> + vector float vb = vec_promote (b, PREF_F);
>>> + return vec_extract (vec_max (va, vb), PREF_F);
>>> +}
>>> +
>>> +float vminf (float a, float b)
>>> +{
>>> + vector float va = vec_promote (a, PREF_F);
>>> + vector float vb = vec_promote (b, PREF_F);
>>> + return vec_extract (vec_min (va, vb), PREF_F);
>>> +}
>>> diff --git a/gcc/testsuite/gcc.target/powerpc/vec-minmax-2.c
>>> b/gcc/testsuite/gcc.target/powerpc/vec-minmax-2.c
>>> new file mode 100644
>>> index 00000000000..d318b933181
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.target/powerpc/vec-minmax-2.c
>>> @@ -0,0 +1,51 @@
>>> +/* { dg-do compile { target { powerpc64le-*-* } } } */
>>> +/* { dg-require-effective-target powerpc_p9vector_ok } */
>>> +/* { dg-options "-O2 -mdejagnu-cpu=power9 -ffast-math" } */
>>> +/* { dg-final { scan-assembler-times {\mxsmaxcdp\M} 2 } } */
>>> +/* { dg-final { scan-assembler-times {\mxsmincdp\M} 2 } } */
>>> +
>>> +/* This test verifies that float or double vec_min/max can be
>>> converted
>>> + to scalar comparison when fast-math is set. */
>>> +
>>> +
>>> +#include <altivec.h>
>>> +
>>> +#ifdef _BIG_ENDIAN
>>> + const int PREF_D = 0;
>>> +#else
>>> + const int PREF_D = 1;
>>> +#endif
>>> +
>>> +double vmaxd (double a, double b)
>>> +{
>>> + vector double va = vec_promote (a, PREF_D);
>>> + vector double vb = vec_promote (b, PREF_D);
>>> + return vec_extract (vec_max (va, vb), PREF_D);
>>> +}
>>> +
>>> +double vmind (double a, double b)
>>> +{
>>> + vector double va = vec_promote (a, PREF_D);
>>> + vector double vb = vec_promote (b, PREF_D);
>>> + return vec_extract (vec_min (va, vb), PREF_D);
>>> +}
>>> +
>>> +#ifdef _BIG_ENDIAN
>>> + const int PREF_F = 0;
>>> +#else
>>> + const int PREF_F = 3;
>>> +#endif
>>> +
>>> +float vmaxf (float a, float b)
>>> +{
>>> + vector float va = vec_promote (a, PREF_F);
>>> + vector float vb = vec_promote (b, PREF_F);
>>> + return vec_extract (vec_max (va, vb), PREF_F);
>>> +}
>>> +
>>> +float vminf (float a, float b)
>>> +{
>>> + vector float va = vec_promote (a, PREF_F);
>>> + vector float vb = vec_promote (b, PREF_F);
>>> + return vec_extract (vec_min (va, vb), PREF_F);
>>> +}
>>>
next prev parent reply other threads:[~2021-08-25 8:45 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 8:52 HAO CHEN GUI
2021-08-24 20:04 ` Bill Schmidt
2021-08-24 22:40 ` Segher Boessenkool
2021-08-25 7:06 ` HAO CHEN GUI
2021-08-25 7:50 ` Kewen.Lin
2021-08-25 8:17 ` HAO CHEN GUI
2021-08-25 8:44 ` HAO CHEN GUI [this message]
2021-08-25 12:34 ` Bill Schmidt
2021-08-26 1:19 ` HAO CHEN GUI
2021-09-06 6:01 ` HAO CHEN GUI
2021-09-22 6:52 ` PING^2 " HAO CHEN GUI
2021-10-11 5:26 ` PING^3 " HAO CHEN GUI
2021-10-11 15:55 ` Segher Boessenkool
2021-10-11 16:07 ` Segher Boessenkool
2021-10-12 8:57 HAO CHEN GUI
2021-10-12 9:57 ` Richard Biener
2021-10-13 7:43 ` HAO CHEN GUI
2021-10-13 8:29 ` Richard Biener
2021-10-13 9:15 ` HAO CHEN GUI
2021-10-13 18:19 ` Segher Boessenkool
2021-10-13 22:04 ` Joseph Myers
2021-10-13 18:28 ` Segher Boessenkool
2021-10-13 15:02 David Edelsohn
2021-10-20 9:04 HAO CHEN GUI
2021-10-20 16:19 ` Segher Boessenkool
2021-10-21 6:25 ` HAO CHEN GUI
2021-11-01 6:48 HAO CHEN GUI
2021-11-02 0:21 ` David Edelsohn
2021-11-02 2:40 ` HAO CHEN GUI
2021-11-02 13:12 ` David Edelsohn
2021-11-03 2:14 ` HAO CHEN GUI
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=d555d244-5251-4550-c849-ad8e0596e8cb@linux.ibm.com \
--to=guihaoc@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=linkw@linux.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=wschmidt@linux.ibm.com \
/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).