From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8664 invoked by alias); 27 Jun 2013 15:33:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 8654 invoked by uid 89); 27 Jun 2013 15:33:19 -0000 X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 27 Jun 2013 15:33:19 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5RFXGLB027583 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 Jun 2013 11:33:17 -0400 Received: from zalov.cz (vpn1-7-18.ams2.redhat.com [10.36.7.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5RFXEF6004105 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 Jun 2013 11:33:15 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r5RFXDsp023558; Thu, 27 Jun 2013 17:33:13 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r5RFXDXI023557; Thu, 27 Jun 2013 17:33:13 +0200 Date: Thu, 27 Jun 2013 15:40:00 -0000 From: Jakub Jelinek To: Marc Glisse Cc: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [C++] Fix __builtin_shuffle Message-ID: <20130627153313.GE2336@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <51CB558B.6090905@redhat.com> <51CC2F9D.908@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-06/txt/msg01529.txt.bz2 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