From patchwork Thu Feb 19 03:39:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Iyer, Balaji V" X-Patchwork-Id: 441525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0306D14008F for ; Thu, 19 Feb 2015 14:39:34 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; q=dns; s= default; b=ySyWyJWX+/ObXevm7IoNtySmkc77vChCUeBknMIxmM8SD7BYIpnx1 xtqVUlg0V3rNscazobCr0urlFDPT0+FuoBGdaIge0OY1ooU0Sk0AzRIQMaDs+Fhf 1xlOwiOiMoK/1qzj8hFLGNu/IYg3U1OdP/LC973iBMXwZR+iPZZqso= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; s= default; bh=o7PhmnDU9+ObBlNjZHRi/P8i18w=; b=bgY/synklfR+aaErow67 IMPFSjQcuBWHmxCJpPg3nDRJmNqsLldv2iP+J66qN1eNZC8wmOwIXszJ4qXfWPpr kKPj9/tXcQTR7rsCmpzJ5KBLardCVTP+WqvSiDUM+aUApLske9CcGwlh6+WaWCyG AWztuSIC6ZTFajaCru9n9W4= Received: (qmail 29805 invoked by alias); 19 Feb 2015 03:39:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 29792 invoked by uid 89); 19 Feb 2015 03:39:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Feb 2015 03:39:23 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 18 Feb 2015 19:39:21 -0800 X-ExtLoop1: 1 Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by fmsmga002.fm.intel.com with ESMTP; 18 Feb 2015 19:39:20 -0800 Received: from orsmsx157.amr.corp.intel.com (10.22.240.23) by ORSMSX102.amr.corp.intel.com (10.22.225.129) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 18 Feb 2015 19:39:20 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by ORSMSX157.amr.corp.intel.com (10.22.240.23) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 18 Feb 2015 19:39:20 -0800 Received: from fmsmsx101.amr.corp.intel.com ([169.254.1.19]) by fmsmsx120.amr.corp.intel.com ([169.254.15.131]) with mapi id 14.03.0195.001; Wed, 18 Feb 2015 19:39:19 -0800 From: "Iyer, Balaji V" To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] Fix for PR c++/60269 Date: Thu, 19 Feb 2015 03:39:19 +0000 Message-ID: MIME-Version: 1.0 Hello Everyone,                 Attached, please find a patch that is a fix for PR c++/60269. Tested on x86_64 and have no regression issues. Is this OK for trunk? Thanks, Balaji V. Iyer. +2015-02-18  Balaji V. Iyer  + +       PR c++/60269 +       * parser.c (cp_parser_cilk_simd_vectorlength): Added a check for +       template handling.  If so, then defer the validity checks to pt.c. +       * pt.c (tsubst_omp_clauses): Added a check for invalid vectorlength +       for Cilk Plus SIMD loops. + +2015-02-18  Balaji V. Iyer  + +       PR c++/60269 +       * g++.dg/cilk-plus/pr60269.C: New test. + diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e0b455c..97ddee4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -33207,13 +33207,19 @@ cp_parser_cilk_simd_vectorlength (cp_parser *parser, tree clauses, error mark node then they would have emitted an error message. */ if (expr == error_mark_node) ; - else if (!TREE_TYPE (expr) - || !TREE_CONSTANT (expr) - || !INTEGRAL_TYPE_P (TREE_TYPE (expr))) - error_at (loc, "vectorlength must be an integer constant"); - else if (TREE_CONSTANT (expr) + else if (!processing_template_decl + && (!TREE_TYPE (expr) || !TREE_CONSTANT (expr) + || !INTEGRAL_TYPE_P (TREE_TYPE (expr)))) + { + error_at (loc, "vectorlength must be an integer constant"); + expr = error_mark_node; + } + else if (!processing_template_decl && TREE_CONSTANT (expr) && exact_log2 (TREE_INT_CST_LOW (expr)) == -1) - error_at (loc, "vectorlength must be a power of 2"); + { + error_at (loc, "vectorlength must be a power of 2"); + expr = error_mark_node; + } else { tree c; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9a00d0d..dc1bae8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13491,6 +13491,18 @@ tsubst_omp_clauses (tree clauses, bool declare_simd, OMP_CLAUSE_OPERAND (nc, 0) = tsubst_expr (OMP_CLAUSE_OPERAND (oc, 0), args, complain, in_decl, /*integral_constant_expression_p=*/false); + if (flag_cilkplus && OMP_CLAUSE_CODE (nc) == OMP_CLAUSE_SAFELEN) + { + tree new_expr = OMP_CLAUSE_OPERAND (nc, 0); + if (!new_expr || new_expr == error_mark_node) + ; + else if (!TREE_TYPE (new_expr) || !TREE_CONSTANT (new_expr) + || !INTEGRAL_TYPE_P (TREE_TYPE (new_expr))) + error ("vectorlength must be an integer constant"); + else if (TREE_CONSTANT (new_expr) + && exact_log2 (TREE_INT_CST_LOW (new_expr)) == -1) + error ("vectorlength must be a power of 2"); + } break; case OMP_CLAUSE_REDUCTION: if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (oc)) diff --git a/gcc/testsuite/g++.dg/cilk-plus/pr60269.C b/gcc/testsuite/g++.dg/cilk-plus/pr60269.C new file mode 100644 index 0000000..fa0c25b --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/pr60269.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-O3 -fcilkplus" } + +template +void foo (int *a, int *b, int *c) +{ +#pragma simd vectorlength (N) + for (int i = 0; i < N; i++) + a[i] = b[i] * c[i]; +} + +void +bar (int *a, int *b, int *c) +{ + foo <64> (a, b, c); +} +