From patchwork Sun May 25 09:31:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zamyatin, Igor" X-Patchwork-Id: 352234 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 B6DFE140085 for ; Sun, 25 May 2014 19:32:03 +1000 (EST) 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=gHoFCPtWKQKgfN/YqRUI8Fgj8m0AGYZuTk+VG3PJ+mFBAQUQHbdzd ffG7b4CRmwwAFXIGtBKy5hON5bPcYIZAKKLCK25cHVPH4qSFgLOVJy5hKkXjvKNn Quiz4YTGOs7RNtQ4QDDmW5T9tjdtQzbH8W+sxcnCL7cUCbsOitajw0= 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=Df3puoYQZ2+rbf0u4btlBihPCLE=; b=EGqziGUFkQZ8+dYjTdjA utNBsQfH88wVC4OXF/VrUq7xWQILoUGA0ukNGPAWxYLaaPtcLFvHcvvGnNWXl+I8 WW/xLzCR9jd288/2j++UFwtOKfHrGpaPEcs8oqGvOxw6whHl9/RahOBptT0B8cG8 1r6eliLykZLrYu9GfdacgPY= Received: (qmail 29031 invoked by alias); 25 May 2014 09:31:56 -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 29020 invoked by uid 89); 25 May 2014 09:31:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 May 2014 09:31:54 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 25 May 2014 02:31:53 -0700 X-ExtLoop1: 1 Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga001.jf.intel.com with ESMTP; 25 May 2014 02:31:52 -0700 Received: from irsmsx153.ger.corp.intel.com (163.33.192.75) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sun, 25 May 2014 10:31:51 +0100 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.245]) by IRSMSX153.ger.corp.intel.com ([169.254.9.252]) with mapi id 14.03.0123.003; Sun, 25 May 2014 10:31:51 +0100 From: "Zamyatin, Igor" To: "GCC Patches (gcc-patches@gcc.gnu.org)" Subject: [PATCH, PR58942, Cilk+] Fix ICE when pointer is used in array notation Date: Sun, 25 May 2014 09:31:50 +0000 Message-ID: <0EFAB2BDD0F67E4FB6CCC8B9F87D756956456365@IRSMSX101.ger.corp.intel.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi! Following patch handles the case of pointers in Cilk+ builtins. Regtested in x86_64. Ok for trunk and 4.9? Thanks, Igor gcc/c/ChangeLog: 2014-05-23 Igor Zamyatin PR c/58942 * c-array-notation.c (fix_builtin_array_notation_fn): Handle the case with a pointer. gcc/cp/ChangeLog: 2014-05-23 Igor Zamyatin PR c/58942 * cp-array-notation.c (expand_sec_reduce_builtin): Handle the case with a pointer. gcc/testsuite/ChangeLog 2014-05-23 Igor Zamyatin PR c/58942 * c-c++-common/cilk-plus/AN/pr58942.c: Check for correct handling of the case with a pointer. diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 0ac6ba8..42fc9e1 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -308,7 +308,9 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var) || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND) array_ind_value = build_decl (location, VAR_DECL, NULL_TREE, TREE_TYPE (func_parm)); - array_op0 = (*array_operand)[0]; + array_op0 = (*array_operand)[0]; + if (TREE_CODE (array_op0) == INDIRECT_REF) + array_op0 = TREE_OPERAND (array_op0, 0); switch (an_type) { case BUILT_IN_CILKPLUS_SEC_REDUCE_ADD: diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index 65b8bcb..71312db 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -340,6 +340,8 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree *new_var) array_ind_value = get_temp_regvar (TREE_TYPE (func_parm), func_parm); array_op0 = (*array_operand)[0]; + if (TREE_CODE (array_op0) == INDIRECT_REF) + array_op0 = TREE_OPERAND (array_op0, 0); switch (an_type) { case BUILT_IN_CILKPLUS_SEC_REDUCE_ADD: diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c new file mode 100644 index 0000000..87903af --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c @@ -0,0 +1,8 @@ +/* PR c/58942 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int foo (int*p, int i) +{ + return __sec_reduce_max_ind(p[1:i]); +}