From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8F6233858403; Tue, 8 Nov 2022 06:11:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F6233858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667887868; bh=TrNZ3FBetKda6QCOJcbqLO/EonYqIjppJHIt2817LOs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qif8DeOo3iZrzrCqz3ehHqWyTOpH6u7+kAAs0h6+ylI/nOk4sb8ZVRwEukfbwoL+0 86l8qsEbQBEj8jy1o8vbBNjQw2ubxb+pVd3VdZKSr+u6Ohnx2TRO9Hwh7cQAsSUJfH MvovnaY9ORnb+P70LoKE76a1A7luV835SQYRah78= From: "unlvsur at live dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: unlvsur at live dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107563 --- Comment #7 from cqwrteur --- (In reply to Hongtao.liu from comment #6) > Shufd only handles >=20 > void foo1(temp_vec_type& v) noexcept > { > v=3D__builtin_shufflevector(v,v,12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3); > } >=20 > 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)]]= =3D int; using x86_64_v16qi [[__gnu__::__vector_size__ (16)]= ] =3D char; using x86_64_v8hi [[__gnu__::__vector_size__ (16)]]= =3D short; constexpr x86_64_v16qi zero{}; if constexpr(sizeof(T)=3D=3D8) { 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=3D__builtin_ia32_packuswb128(res3,= res7); } else if constexpr(sizeof(T)=3D=3D4) { 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=3D__builtin_ia32_packuswb128(res3,= res7); } else if constexpr(sizeof(T)=3D=3D2) { using x86_64_v8hu [[__gnu__::__vector_size__ (16)]] =3D unsigned short; auto res0{(x86_64_v8hu)temp_vec}; temp_vec=3D(x86_64_v16qi)((res0>>8)|(res0<<= 8)); }=