public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001]
@ 2022-06-17  7:28 Jakub Jelinek
  2022-06-17 13:28 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2022-06-17  7:28 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2022-06-17  Jakub Jelinek  <jakub@redhat.com>

	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.

--- gcc/cp/typeck.cc.jj	2022-06-04 10:34:26.261505682 +0200
+++ gcc/cp/typeck.cc	2022-06-16 19:38:04.397979247 +0200
@@ -6344,7 +6344,7 @@ build_x_shufflevector (location_t loc, v
   auto_vec<tree, 16> 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);
--- gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C.jj	2022-06-16 19:43:13.103935249 +0200
+++ gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C	2022-06-16 19:42:37.534401207 +0200
@@ -0,0 +1,18 @@
+// PR c++/106001
+// { dg-do compile }
+
+typedef int V __attribute__((vector_size (2 * sizeof (int))));
+
+template <int>
+void
+foo ()
+{
+  V v = {};
+  v = __builtin_shufflevector (v, v, static_cast<char>(1), static_cast<char>(0));
+}
+
+void
+bar ()
+{
+  foo <0> ();
+}

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001]
  2022-06-17  7:28 [PATCH] c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001] Jakub Jelinek
@ 2022-06-17 13:28 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2022-06-17 13:28 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 6/17/22 03:28, Jakub Jelinek wrote:
> Hi!
> 
> 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.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 2022-06-17  Jakub Jelinek  <jakub@redhat.com>
> 
> 	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.
> 
> --- gcc/cp/typeck.cc.jj	2022-06-04 10:34:26.261505682 +0200
> +++ gcc/cp/typeck.cc	2022-06-16 19:38:04.397979247 +0200
> @@ -6344,7 +6344,7 @@ build_x_shufflevector (location_t loc, v
>     auto_vec<tree, 16> 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);
> --- gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C.jj	2022-06-16 19:43:13.103935249 +0200
> +++ gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C	2022-06-16 19:42:37.534401207 +0200
> @@ -0,0 +1,18 @@
> +// PR c++/106001
> +// { dg-do compile }
> +
> +typedef int V __attribute__((vector_size (2 * sizeof (int))));
> +
> +template <int>
> +void
> +foo ()
> +{
> +  V v = {};
> +  v = __builtin_shufflevector (v, v, static_cast<char>(1), static_cast<char>(0));
> +}
> +
> +void
> +bar ()
> +{
> +  foo <0> ();
> +}
> 
> 	Jakub
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-17 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17  7:28 [PATCH] c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001] Jakub Jelinek
2022-06-17 13:28 ` Jason Merrill

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).