public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Marc Glisse <marc.glisse@inria.fr>
Cc: Jason Merrill <jason@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [C++] Fix __builtin_shuffle
Date: Thu, 27 Jun 2013 15:40:00 -0000	[thread overview]
Message-ID: <20130627153313.GE2336@tucnak.redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1306271719330.26429@stedding.saclay.inria.fr>

On Thu, Jun 27, 2013 at 05:24:45PM +0200, Marc Glisse wrote:
> On Thu, 27 Jun 2013, Jason Merrill wrote:
> 
> >On 06/27/2013 07:59 AM, Marc Glisse wrote:
> >>I assume I can't call directly c_build_vec_perm_expr on the original
> >>arguments without build_non_dependent_expr?
> >
> >It looks like c_build_vec_perm_expr is safe to take the original
> >arguments, since it doesn't look deep into the expression.  So
> >either way is fine.
> 
> Cool, I'll go with the short version then (I tested it before posting):
> 
> +tree
> +build_x_vec_perm_expr (location_t loc,
> +			tree arg0, tree arg1, tree arg2,
> +			tsubst_flags_t complain)
> +{
> +  if (processing_template_decl
> +      && (type_dependent_expression_p (arg0)
> +	  || type_dependent_expression_p (arg1)
> +	  || type_dependent_expression_p (arg2)))
> +    return build_min_nt_loc (loc, VEC_PERM_EXPR, arg0, arg1, arg2);
> +  return c_build_vec_perm_expr (loc, arg0, arg1, arg2, complain & tf_error);
> +}

But then you won't diagnose errors in never instantiated templates that
could be diagnosed (i.e. where the arguments aren't type dependent).
I think the standard C++ FE way is doing something like:

+  tree expr;
+  tree orig_arg0 = arg0;
+  tree orig_arg1 = arg1;
+  tree orig_arg2 = arg2;
+  if (processing_template_decl)
+    {
+      if (type_dependent_expression_p (arg0)
+	  || type_dependent_expression_p (arg1)
+	  || type_dependent_expression_p (arg2))
+	return build_min_nt_loc (loc, VEC_PERM_EXPR, arg0, arg1, arg2);
+      arg0 = build_non_dependent_expr (arg0);
+      arg1 = build_non_dependent_expr (arg1);
+      arg2 = build_non_dependent_expr (arg2);
+    }
+  expr = c_build_vec_perm_expr (loc, arg0, arg1, arg2, complain & tf_error);
+  if (processing_template_decl && expr != error_mark_node)
+    return build_min_nt_loc (loc, VEC_PERM_EXPR, orig_arg0, orig_arg1,
+			     orig_arg2);
+  return expr;

	Jakub

  reply	other threads:[~2013-06-27 15:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09 11:09 Marc Glisse
2013-06-26 14:20 ` Marc Glisse
2013-06-26 20:56 ` Jason Merrill
2013-06-27 11:59   ` Marc Glisse
2013-06-27 12:27     ` Jason Merrill
2013-06-27 15:29       ` Marc Glisse
2013-06-27 15:40         ` Jakub Jelinek [this message]
2013-06-27 15:55           ` Marc Glisse
2013-06-27 16:09             ` Jakub Jelinek
2013-06-27 16:10               ` Marc Glisse
2013-06-27 21:58                 ` Marc Glisse
2013-06-28  6:20     ` Jakub Jelinek
2013-06-28  8:48       ` Marc Glisse
2013-06-28 10:34         ` Marc Glisse

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=20130627153313.GE2336@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=marc.glisse@inria.fr \
    /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: link
Be 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).