[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 Andrew Pinski changed: What|Removed |Added Target Milestone|--- |12.0
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 Marek Polacek changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #8 from Marek Polacek --- Fixed.
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 --- Comment #7 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:1ba397e9f93d3abc93a6ecbabc3d873489a6fb7f commit r12-8248-g1ba397e9f93d3abc93a6ecbabc3d873489a6fb7f Author: Marek Polacek Date: Fri Apr 22 19:40:27 2022 -0400 c++: __builtin_shufflevector with value-dep expr [PR105353] Here we issue an error from c_build_shufflevector while parsing a template because it got a TEMPLATE_PARM_INDEX, but this function expects INTEGER_CSTs (except the first two arguments). It checks if any of the arguments are type-dependent, if so, we leave the processing for later, but it should also check value-dependency for the 3rd+ arguments, so as to avoid the problem above. This is not a regression -- __builtin_shufflevector was introduced in GCC 12, but it looks safe enough. PR c++/105353 gcc/cp/ChangeLog: * typeck.cc (build_x_shufflevector): Use instantiation_dependent_expression_p except for the first two arguments. gcc/testsuite/ChangeLog: * g++.dg/ext/builtin-shufflevector-3.C: New test.
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 --- Comment #6 from Marek Polacek --- Good point, I suppose this is better: --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -6315,7 +6315,9 @@ build_x_shufflevector (location_t loc, vec *args, if (processing_template_decl) { for (unsigned i = 0; i < args->length (); ++i) - if (type_dependent_expression_p ((*args)[i])) + if (i <= 1 + ? type_dependent_expression_p ((*args)[i]) + : instantiation_dependent_expression_p ((*args)[i])) { tree exp = build_min_nt_call_vec (NULL, args); CALL_EXPR_IFN (exp) = IFN_SHUFFLEVECTOR;
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 --- Comment #5 from Jakub Jelinek --- Maybe, but for i <= 1 IMHO type_dependent_expression_p is right, that is why we build_non_dependent_expr, c_build_shufflevector oesn't care about those exact values.
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 --- Comment #4 from Marek Polacek --- My fix is just --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -6315,7 +6315,7 @@ build_x_shufflevector (location_t loc, vec *args, if (processing_template_decl) { for (unsigned i = 0; i < args->length (); ++i) - if (type_dependent_expression_p ((*args)[i])) + if (instantiation_dependent_expression_p ((*args)[i])) { tree exp = build_min_nt_call_vec (NULL, args); CALL_EXPR_IFN (exp) = IFN_SHUFFLEVECTOR; so what we leave the IFN_SHUFFLEVECTOR to be processed when instantiating. fold_non_dependent_expr wouldn't know what to substitute T with yet.
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- As c_build_shufflevector requires that the 3rd+ args are all INTEGER_CSTs that fit into shwi, I think we need to avoid calling that function if any of those isn't such and processing_template_decl. Perhaps we can fold_non_dependent_expr them first.
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 Marek Polacek changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org Status|NEW |ASSIGNED CC||mpolacek at gcc dot gnu.org --- Comment #2 from Marek Polacek --- Right. I have a fix.
[Bug c++/105353] __builtin_shufflevector with value dependent constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105353 Andrew Pinski changed: What|Removed |Added Summary|__builtin_shufflevector |__builtin_shufflevector |with template parameter |with value dependent |fails to compile on GCC 12 |constant |but compiles on clang | Ever confirmed|0 |1 Last reconfirmed||2022-04-22 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski --- Confirmed, it is all value dependent constants really. e.g. even sizeof fails: #include typedef std::uint8_t Simd128U8VectT __attribute__((__vector_size__(16))); #define ShuffleIndex sizeof(T) template 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); }