From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id A80E63857344; Fri, 17 Jun 2022 15:41:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A80E63857344 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1158] c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handlin X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: cc378e655740e93743e7f43e14faaff707aef6c1 X-Git-Newrev: a284fadcce8ef443cc3cc047a8017745efb51758 Message-Id: <20220617154123.A80E63857344@sourceware.org> Date: Fri, 17 Jun 2022 15:41:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 15:41:23 -0000 https://gcc.gnu.org/g:a284fadcce8ef443cc3cc047a8017745efb51758 commit r13-1158-ga284fadcce8ef443cc3cc047a8017745efb51758 Author: Jakub Jelinek Date: Fri Jun 17 17:40:49 2022 +0200 c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001] In this case the STATIC_CAST_EXPR expressions in the call aren't type nor value dependent, but maybe_constant_value still ICEs on those when processing_template_decl. Calling fold_non_dependent_expr on it instead fixes the ICE and folds them to INTEGER_CSTs. 2022-06-17 Jakub Jelinek PR c++/106001 * typeck.cc (build_x_shufflevector): Use fold_non_dependent_expr instead of maybe_constant_value. * g++.dg/ext/builtin-shufflevector-4.C: New test. Diff: --- gcc/cp/typeck.cc | 2 +- gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index f9ce14fe72a..6e4f23af982 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -6344,7 +6344,7 @@ build_x_shufflevector (location_t loc, vec *args, auto_vec mask; for (unsigned i = 2; i < args->length (); ++i) { - tree idx = maybe_constant_value ((*args)[i]); + tree idx = fold_non_dependent_expr ((*args)[i], complain); mask.safe_push (idx); } tree exp = c_build_shufflevector (loc, arg0, arg1, mask, complain & tf_error); diff --git a/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C b/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C new file mode 100644 index 00000000000..dae129b11d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C @@ -0,0 +1,18 @@ +// PR c++/106001 +// { dg-do compile } + +typedef int V __attribute__((vector_size (2 * sizeof (int)))); + +template +void +foo () +{ + V v = {}; + v = __builtin_shufflevector (v, v, static_cast(1), static_cast(0)); +} + +void +bar () +{ + foo <0> (); +}