* [PATCH] [i386] Don't fold __builtin_ia32_blendvpd w/o sse4.2.
@ 2022-03-16 8:17 liuhongt
2022-03-16 8:41 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: liuhongt @ 2022-03-16 8:17 UTC (permalink / raw)
To: gcc-patches
__builtin_ia32_blendvpd is defined under sse4.1 and gimple folded
to ((v2di) c) < 0 ? b : a where vec_cmpv2di is under sse4.2 w/o which
it's veclowered to scalar operations and not combined back in rtl.
Bootstrap and regtest on x86_64-pc-linux-gnu{-m32,}.
Ready push to main trunk.
gcc/ChangeLog:
PR target/104946
* config/i386/i386-builtin.def (BDESC): Add
CODE_FOR_sse4_1_blendvpd for IX86_BUILTIN_BLENDVPD.
* config/i386/i386.cc (ix86_gimple_fold_builtin): Don't fold
__builtin_ia32_blendvpd w/o sse4.2
gcc/testsuite/ChangeLog:
* gcc.target/i386/sse4_1-blendvpd-1.c: New test.
---
gcc/config/i386/i386-builtin.def | 2 +-
gcc/config/i386/i386.cc | 8 +++++++-
gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c | 11 +++++++++++
3 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c
diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def
index ea327555639..b410102614d 100644
--- a/gcc/config/i386/i386-builtin.def
+++ b/gcc/config/i386/i386-builtin.def
@@ -906,7 +906,7 @@ BDESC (OPTION_MASK_ISA_SSSE3 | OPTION_MASK_ISA_MMX, 0, CODE_FOR_ssse3_palignrdi,
/* SSE4.1 */
BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_blendpd, "__builtin_ia32_blendpd", IX86_BUILTIN_BLENDPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT)
BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_blendps, "__builtin_ia32_blendps", IX86_BUILTIN_BLENDPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT)
-BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_nothing, "__builtin_ia32_blendvpd", IX86_BUILTIN_BLENDVPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_V2DF)
+BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_blendvpd, "__builtin_ia32_blendvpd", IX86_BUILTIN_BLENDVPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_V2DF)
BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_nothing, "__builtin_ia32_blendvps", IX86_BUILTIN_BLENDVPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_V4SF)
BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_dppd, "__builtin_ia32_dppd", IX86_BUILTIN_DPPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT)
BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_dpps, "__builtin_ia32_dpps", IX86_BUILTIN_DPPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT)
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index d77ad83e437..5a561966eb4 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -18368,10 +18368,16 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi)
}
break;
+ case IX86_BUILTIN_BLENDVPD:
+ /* blendvpd is under sse4.1 but pcmpgtq is under sse4.2,
+ w/o sse4.2, it's veclowered to scalar operations and
+ not combined back. */
+ if (!TARGET_SSE4_2)
+ break;
+ /* FALLTHRU. */
case IX86_BUILTIN_PBLENDVB128:
case IX86_BUILTIN_PBLENDVB256:
case IX86_BUILTIN_BLENDVPS:
- case IX86_BUILTIN_BLENDVPD:
case IX86_BUILTIN_BLENDVPS256:
case IX86_BUILTIN_BLENDVPD256:
gcc_assert (n_args == 3);
diff --git a/gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c b/gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c
new file mode 100644
index 00000000000..c25d3fbcbd4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-msse4.1 -O2 -mno-sse4.2" } */
+/* { dg-final { scan-assembler-times {(?n)blendvpd[ \t]+%xmm[0-9]+} 1 } } */
+
+#include <immintrin.h>
+
+__m128d
+foo (__m128d a, __m128d b, __m128d c)
+{
+ return _mm_blendv_pd (a, b, c);
+}
--
2.18.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [i386] Don't fold __builtin_ia32_blendvpd w/o sse4.2.
2022-03-16 8:17 [PATCH] [i386] Don't fold __builtin_ia32_blendvpd w/o sse4.2 liuhongt
@ 2022-03-16 8:41 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-03-16 8:41 UTC (permalink / raw)
To: liuhongt; +Cc: GCC Patches
On Wed, Mar 16, 2022 at 9:18 AM liuhongt via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> __builtin_ia32_blendvpd is defined under sse4.1 and gimple folded
> to ((v2di) c) < 0 ? b : a where vec_cmpv2di is under sse4.2 w/o which
> it's veclowered to scalar operations and not combined back in rtl.
>
> Bootstrap and regtest on x86_64-pc-linux-gnu{-m32,}.
> Ready push to main trunk.
OK.
Richard.
> gcc/ChangeLog:
>
> PR target/104946
> * config/i386/i386-builtin.def (BDESC): Add
> CODE_FOR_sse4_1_blendvpd for IX86_BUILTIN_BLENDVPD.
> * config/i386/i386.cc (ix86_gimple_fold_builtin): Don't fold
> __builtin_ia32_blendvpd w/o sse4.2
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/i386/sse4_1-blendvpd-1.c: New test.
> ---
> gcc/config/i386/i386-builtin.def | 2 +-
> gcc/config/i386/i386.cc | 8 +++++++-
> gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c | 11 +++++++++++
> 3 files changed, 19 insertions(+), 2 deletions(-)
> create mode 100644 gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c
>
> diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def
> index ea327555639..b410102614d 100644
> --- a/gcc/config/i386/i386-builtin.def
> +++ b/gcc/config/i386/i386-builtin.def
> @@ -906,7 +906,7 @@ BDESC (OPTION_MASK_ISA_SSSE3 | OPTION_MASK_ISA_MMX, 0, CODE_FOR_ssse3_palignrdi,
> /* SSE4.1 */
> BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_blendpd, "__builtin_ia32_blendpd", IX86_BUILTIN_BLENDPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT)
> BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_blendps, "__builtin_ia32_blendps", IX86_BUILTIN_BLENDPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT)
> -BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_nothing, "__builtin_ia32_blendvpd", IX86_BUILTIN_BLENDVPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_V2DF)
> +BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_blendvpd, "__builtin_ia32_blendvpd", IX86_BUILTIN_BLENDVPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_V2DF)
> BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_nothing, "__builtin_ia32_blendvps", IX86_BUILTIN_BLENDVPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_V4SF)
> BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_dppd, "__builtin_ia32_dppd", IX86_BUILTIN_DPPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT)
> BDESC (OPTION_MASK_ISA_SSE4_1, 0, CODE_FOR_sse4_1_dpps, "__builtin_ia32_dpps", IX86_BUILTIN_DPPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT)
> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
> index d77ad83e437..5a561966eb4 100644
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -18368,10 +18368,16 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi)
> }
> break;
>
> + case IX86_BUILTIN_BLENDVPD:
> + /* blendvpd is under sse4.1 but pcmpgtq is under sse4.2,
> + w/o sse4.2, it's veclowered to scalar operations and
> + not combined back. */
> + if (!TARGET_SSE4_2)
> + break;
> + /* FALLTHRU. */
> case IX86_BUILTIN_PBLENDVB128:
> case IX86_BUILTIN_PBLENDVB256:
> case IX86_BUILTIN_BLENDVPS:
> - case IX86_BUILTIN_BLENDVPD:
> case IX86_BUILTIN_BLENDVPS256:
> case IX86_BUILTIN_BLENDVPD256:
> gcc_assert (n_args == 3);
> diff --git a/gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c b/gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c
> new file mode 100644
> index 00000000000..c25d3fbcbd4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/sse4_1-blendvpd-1.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-msse4.1 -O2 -mno-sse4.2" } */
> +/* { dg-final { scan-assembler-times {(?n)blendvpd[ \t]+%xmm[0-9]+} 1 } } */
> +
> +#include <immintrin.h>
> +
> +__m128d
> +foo (__m128d a, __m128d b, __m128d c)
> +{
> + return _mm_blendv_pd (a, b, c);
> +}
> --
> 2.18.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-16 8:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 8:17 [PATCH] [i386] Don't fold __builtin_ia32_blendvpd w/o sse4.2 liuhongt
2022-03-16 8:41 ` Richard Biener
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).