public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "john_platts at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105353] New: __builtin_shufflevector with template parameter fails to compile on GCC 12 but compiles on clang Date: Fri, 22 Apr 2022 21:07:58 +0000 [thread overview] Message-ID: <bug-105353-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 Bug ID: 105353 Summary: __builtin_shufflevector with template parameter fails to compile on GCC 12 but compiles on clang Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: john_platts at hotmail dot com Target Milestone: --- The following code fails to compile with GCC 12 but compiles successfully on clang (with the -std=c++17 flag): #include <cstdint> typedef std::uint8_t Simd128U8VectT __attribute__((__vector_size__(16))); template<int ShuffleIndex> static inline Simd128U8VectT ShufFunc(Simd128U8VectT vect) noexcept { if constexpr(unsigned(ShuffleIndex) >= 16) return Simd128U8VectT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; else if constexpr(ShuffleIndex == 0) return vect; else return __builtin_shufflevector(vect, vect, ShuffleIndex, ShuffleIndex + 1, ShuffleIndex + 2, ShuffleIndex + 3, ShuffleIndex + 4, ShuffleIndex + 5, ShuffleIndex + 6, ShuffleIndex + 7, ShuffleIndex + 8, ShuffleIndex + 9, ShuffleIndex + 10, ShuffleIndex + 11, ShuffleIndex + 12, ShuffleIndex + 13, ShuffleIndex + 14, ShuffleIndex + 15); } auto func1(Simd128U8VectT vect) noexcept { return ShufFunc<5>(vect); } Here is the assembly output when the above code is compiled on clang 14.0.0 with the -O2 -std=c++17 flags: func1(unsigned char __vector(16)): # @func1(unsigned char __vector(16)) movdqa xmm1, xmm0 psrldq xmm1, 5 # xmm1 = xmm1[5,6,7,8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero pslldq xmm0, 11 # xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3,4] por xmm0, xmm1 ret The below code compiles successfully with GCC 11 and GCC 12 (which uses __builtin_shuffle instead of __builtin_shufflevector): #include <cstdint> typedef std::uint8_t Simd128U8VectT __attribute__((__vector_size__(16))); template<int ShuffleIndex> static inline Simd128U8VectT ShufFunc(Simd128U8VectT vect) noexcept { if constexpr(unsigned(ShuffleIndex) >= 16) return Simd128U8VectT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; else if constexpr(ShuffleIndex == 0) return vect; else return __builtin_shuffle(vect, vect, (Simd128U8VectT){ ShuffleIndex, ShuffleIndex + 1, ShuffleIndex + 2, ShuffleIndex + 3, ShuffleIndex + 4, ShuffleIndex + 5, ShuffleIndex + 6, ShuffleIndex + 7, ShuffleIndex + 8, ShuffleIndex + 9, ShuffleIndex + 10, ShuffleIndex + 11, ShuffleIndex + 12, ShuffleIndex + 13, ShuffleIndex + 14, ShuffleIndex + 15 }); } auto func1(Simd128U8VectT vect) noexcept { return ShufFunc<5>(vect); }
next reply other threads:[~2022-04-22 21:07 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-22 21:07 john_platts at hotmail dot com [this message] 2022-04-22 21:21 ` [Bug c++/105353] __builtin_shufflevector with value dependent constant pinskia at gcc dot gnu.org 2022-04-22 21:40 ` mpolacek at gcc dot gnu.org 2022-04-22 21:50 ` jakub at gcc dot gnu.org 2022-04-22 21:55 ` mpolacek at gcc dot gnu.org 2022-04-22 21:59 ` jakub at gcc dot gnu.org 2022-04-22 22:04 ` mpolacek at gcc dot gnu.org 2022-04-25 15:16 ` cvs-commit at gcc dot gnu.org 2022-04-25 15:16 ` mpolacek at gcc dot gnu.org 2022-10-31 19:31 ` pinskia at gcc dot gnu.org
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-105353-4@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: linkBe 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).