public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "unlvsur at live dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/107563] __builtin_shufflevector fails to pshufd instructions under default x86_64 compilation toggle which is the sse2 one
Date: Tue, 08 Nov 2022 06:11:08 +0000 [thread overview]
Message-ID: <bug-107563-4-YoahemLfXe@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107563-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107563
--- Comment #7 from cqwrteur <unlvsur at live dot com> ---
(In reply to Hongtao.liu from comment #6)
> Shufd only handles
>
> void foo1(temp_vec_type& v) noexcept
> {
> v=__builtin_shufflevector(v,v,12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3);
> }
>
> Not the case in #c0.
I am using it for byte swap
actually, clang has a solution
using x86_64_v4si [[__gnu__::__vector_size__ (16)]] =
int;
using x86_64_v16qi [[__gnu__::__vector_size__ (16)]] =
char;
using x86_64_v8hi [[__gnu__::__vector_size__ (16)]] =
short;
constexpr x86_64_v16qi zero{};
if constexpr(sizeof(T)==8)
{
auto
res0{__builtin_ia32_punpcklbw128(temp_vec,zero)};
auto
res1{__builtin_ia32_pshufd((x86_64_v4si)res0,78)};
auto
res2{__builtin_ia32_pshuflw((x86_64_v8hi)res1,27)};
auto res3{__builtin_ia32_pshufhw(res2,27)};
auto
res4{__builtin_ia32_punpckhbw128(temp_vec,zero)};
auto
res5{__builtin_ia32_pshufd((x86_64_v4si)res4,78)};
auto
res6{__builtin_ia32_pshuflw((x86_64_v8hi)res5,27)};
auto res7{__builtin_ia32_pshufhw(res6,27)};
temp_vec=__builtin_ia32_packuswb128(res3,res7);
}
else if constexpr(sizeof(T)==4)
{
auto
res0{__builtin_ia32_punpcklbw128(temp_vec,zero)};
auto
res2{__builtin_ia32_pshuflw((x86_64_v8hi)res0,27)};
auto res3{__builtin_ia32_pshufhw(res2,27)};
auto
res4{__builtin_ia32_punpckhbw128(temp_vec,zero)};
auto
res6{__builtin_ia32_pshuflw((x86_64_v8hi)res4,27)};
auto res7{__builtin_ia32_pshufhw(res6,27)};
temp_vec=__builtin_ia32_packuswb128(res3,res7);
}
else if constexpr(sizeof(T)==2)
{
using x86_64_v8hu [[__gnu__::__vector_size__
(16)]] = unsigned short;
auto res0{(x86_64_v8hu)temp_vec};
temp_vec=(x86_64_v16qi)((res0>>8)|(res0<<8));
}
next prev parent reply other threads:[~2022-11-08 6:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 22:56 [Bug rtl-optimization/107563] New: __builtin_shufflevector fails to use pshufb and " unlvsur at live dot com
2022-11-07 23:00 ` [Bug target/107563] " unlvsur at live dot com
2022-11-07 23:05 ` [Bug target/107563] __builtin_shufflevector fails to " unlvsur at live dot com
2022-11-08 0:11 ` unlvsur at live dot com
2022-11-08 0:11 ` unlvsur at live dot com
2022-11-08 3:23 ` crazylht at gmail dot com
2022-11-08 3:33 ` crazylht at gmail dot com
2022-11-08 6:11 ` unlvsur at live dot com [this message]
2022-11-08 6:11 ` unlvsur at live dot com
2022-11-08 6:14 ` unlvsur at live dot com
2022-11-08 8:28 ` crazylht at gmail dot com
2024-05-15 4:47 ` cvs-commit at gcc dot gnu.org
2024-05-18 15:17 ` admin at levyhsu dot com
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=bug-107563-4-YoahemLfXe@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@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).