From patchwork Mon Aug 12 17:16:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iyer, Balaji V" X-Patchwork-Id: 266587 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 6EAA22C00FA for ; Tue, 13 Aug 2013 03:18:38 +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:cc:subject:date:message-id:references:in-reply-to :content-type:mime-version; q=dns; s=default; b=qooVngNQMitj3Hiw B/30YJMgj9WkIYhfxuFFK8xdGkJetT8t8bZS4pfQIcD6v9+wQeu4Q0Gdibn1UCzy N6OI29SjdHrPksra4C2skDEw9uLPIksa+jTbFnp5/8gCnXnmSwVajWsj/SrEMaF7 bCVUKuhpbQnVsbnPFJJJMdo0m6o= 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:cc:subject:date:message-id:references:in-reply-to :content-type:mime-version; s=default; bh=O0DgY5DroefB3NHNQ2Q8sa xf9PM=; b=puPJ6TgNZ8zKBU7mgxSpCYOVC29nRVwT1UCDo2ePG4Szo5wf/5bppY +HcF2OCnvLtmkco1HZFmBsX/px8o+RbN62b6IQmz+3+QUW4qi2fY2OG/YDPWXDhe aGLKA9S3zoAPDJOunohpfUPzaVQZvHAn/TkKcNx50sNAbLKEzQNec= Received: (qmail 13089 invoked by alias); 12 Aug 2013 17:18:29 -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 13068 invoked by uid 89); 12 Aug 2013 17:18:28 -0000 X-Spam-SWARE-Status: No, score=-7.2 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 12 Aug 2013 17:18:27 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 12 Aug 2013 10:16:34 -0700 X-ExtLoop1: 1 Received: from fmsmsx105.amr.corp.intel.com ([10.19.9.36]) by azsmga001.ch.intel.com with ESMTP; 12 Aug 2013 10:16:33 -0700 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX105.amr.corp.intel.com (10.19.9.36) with Microsoft SMTP Server (TLS) id 14.3.123.3; Mon, 12 Aug 2013 10:16:33 -0700 Received: from fmsmsx101.amr.corp.intel.com ([169.254.1.119]) by FMSMSX155.amr.corp.intel.com ([169.254.5.73]) with mapi id 14.03.0123.003; Mon, 12 Aug 2013 10:16:32 -0700 From: "Iyer, Balaji V" To: Rainer Orth CC: Jakub Jelinek , "gcc-patches@gcc.gnu.org" , "Marek Polacek (polacek@redhat.com)" Subject: RE: [PATCH] Fix for PR c/57490 Date: Mon, 12 Aug 2013 17:16:32 +0000 Message-ID: References: <20130701162401.GY2336@tucnak.redhat.com> <20130701170926.GB2336@tucnak.redhat.com> In-Reply-To: MIME-Version: 1.0 X-Virus-Found: No > -----Original Message----- > From: Rainer Orth [mailto:ro@CeBiTec.Uni-Bielefeld.DE] > Sent: Friday, August 09, 2013 7:54 AM > To: Iyer, Balaji V > Cc: Jakub Jelinek; gcc-patches@gcc.gnu.org; Marek Polacek > (polacek@redhat.com) > Subject: Re: [PATCH] Fix for PR c/57490 > > Rainer Orth writes: > > > Rainer Orth writes: > > > >> "Iyer, Balaji V" writes: > >> > >>>> -----Original Message----- > >>>> From: Jakub Jelinek [mailto:jakub@redhat.com] > >>>> Sent: Monday, July 01, 2013 1:09 PM > >>>> To: Iyer, Balaji V > >>>> Cc: gcc-patches@gcc.gnu.org; Rainer Orth > >>>> Subject: Re: [PATCH] Fix for PR c/57490 > >>>> > >>>> On Mon, Jul 01, 2013 at 05:02:57PM +0000, Iyer, Balaji V wrote: > >>>> > OK. The fixed patch is attached. Here are the ChangeLog entries: > >>>> > > >>>> > gcc/cp/ChangeLog > >>>> > 2013-07-01 Balaji V. Iyer > >>>> > > >>>> > >>>> Still > >>>> PR c/57490 > >>>> hasn't been added to cp/ChangeLog and c/ChangeLog entries. > >>>> > --- /dev/null > >>>> > +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57490.c > >>>> > @@ -0,0 +1,25 @@ > >>>> > >>> > >>> Fixed as you suggested. Here is the fixed Changelogs and patch is attached. > >>> > >>> gcc/cp/ChangeLog > >>> 2013-07-01 Balaji V. Iyer > >>> > >>> PR c/57490 > >>> * cp-array-notation.c (cp_expand_cond_array_notations): Added a > >>> check for truth values. > >>> (expand_array_notation_exprs): Added truth values case. Removed an > >>> unwanted else. Added for-loop to walk through subtrees in default > >>> case. > >>> > >>> gcc/c/ChangeLog > >>> 2013-07-01 Balaji V. Iyer > >>> > >>> PR c/57490 > >>> * c-array-notation.c (fix_conditional_array_notations_1): Added a > >>> check for truth values. > >>> (expand_array_notation_exprs): Added truth values case. Removed an > >>> unwanted else. Added for-loop to walk through subtrees in default > >>> case. > >>> > >>> > >>> gcc/testsuite/ChangeLog > >>> 2013-07-01 Balaji V. Iyer > >>> > >>> PR c/57490 > >>> * c-c++-common/cilk-plus/AN/pr57490.c: New test. > >> > >> I've just tested this patch on i386-pc-solaris2.10: > >> > >> The c-c++-common/cilk-plus/AN/an-if.c test still FAILs for C++: > >> > >> FAIL: c-c++-common/cilk-plus/AN/an-if.c -fcilkplus (internal > >> compiler error) > >> FAIL: c-c++-common/cilk-plus/AN/an-if.c -fcilkplus (test for excess > >> errors) > [...] > > This is still unfixed almost three weeks later. Balaji, could you > > please have a look? > > This bug is now unfixed for two months, and no reaction whatsoever on the > report. This is getting annoying since it generates large amount of testsuite > noise. > > Please fix ASAP! > Hi Rainer, First off, my sincerest apologies for letting this bug slip the cracks. I am attaching a patch that seem to work fine with the .i file that you have submitted in bugzilla for both C and C++. Please let me know if this fix works for you and if it is OK for trunk. Here are the Changelog entries: gcc/c/ChangeLog 2013-08-12 Balaji V. Iyer PR c/57490 * c-array-notation.c (fix_conditional_array_notations_1): Added a check for truth values. (expand_array_notation_exprs): Added truth values case. Removed an unwanted else. Added for-loop to walk through subtrees in default case. gcc/cp/ChangeLog 2013-08-12 Balaji V. Iyer PR c/57490 * cp-array-notation.c (cp_expand_cond_array_notations): Added a check for truth values. (expand_array_notation_exprs): Added truth values case. Removed an unwanted else. Added for-loop to walk through subtrees in default case. * typeck.c (cp_build_binary_op): Inherited the type of the array notation for built-in array notation functions. gcc/testsuite/ChangeLog 2013-07-01 Balaji V. Iyer PR c/57490 * c-c++-common/cilk-plus/AN/pr57490.c: New test. Yours sincerely, Balaji V. Iyer. > Rainer > > -- > ----------------------------------------------------------------------------- > Rainer Orth, Center for Biotechnology, Bielefeld University diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 7788f7b..5747bcb 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -906,6 +906,8 @@ fix_conditional_array_notations_1 (tree stmt) cond = COND_EXPR_COND (stmt); else if (TREE_CODE (stmt) == SWITCH_EXPR) cond = SWITCH_COND (stmt); + else if (truth_value_p (TREE_CODE (stmt))) + cond = TREE_OPERAND (stmt, 0); else /* Otherwise dont even touch the statement. */ return stmt; @@ -1232,6 +1234,12 @@ expand_array_notation_exprs (tree t) case BIND_EXPR: t = expand_array_notation_exprs (BIND_EXPR_BODY (t)); return t; + case TRUTH_ORIF_EXPR: + case TRUTH_ANDIF_EXPR: + case TRUTH_OR_EXPR: + case TRUTH_AND_EXPR: + case TRUTH_XOR_EXPR: + case TRUTH_NOT_EXPR: case COND_EXPR: t = fix_conditional_array_notations (t); @@ -1246,8 +1254,6 @@ expand_array_notation_exprs (tree t) COND_EXPR_ELSE (t) = expand_array_notation_exprs (COND_EXPR_ELSE (t)); } - else - t = expand_array_notation_exprs (t); return t; case STATEMENT_LIST: { @@ -1284,6 +1290,10 @@ expand_array_notation_exprs (tree t) Replace those with just void zero node. */ t = void_zero_node; default: + for (int ii = 0; ii < TREE_CODE_LENGTH (TREE_CODE (t)); ii++) + if (contains_array_notation_expr (TREE_OPERAND (t, ii))) + TREE_OPERAND (t, ii) = + expand_array_notation_exprs (TREE_OPERAND (t, ii)); return t; } return t; diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index eb6a70d..f4581f0 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -857,6 +857,19 @@ cp_expand_cond_array_notations (tree orig_stmt) return error_mark_node; } } + else if (truth_value_p (TREE_CODE (orig_stmt))) + { + size_t left_rank = 0, right_rank = 0; + tree left_expr = TREE_OPERAND (orig_stmt, 0); + tree right_expr = TREE_OPERAND (orig_stmt, 1); + if (!find_rank (EXPR_LOCATION (left_expr), left_expr, left_expr, true, + &left_rank) + || !find_rank (EXPR_LOCATION (right_expr), right_expr, right_expr, + true, &right_rank)) + return error_mark_node; + if (right_rank == 0 && left_rank == 0) + return orig_stmt; + } if (!find_rank (EXPR_LOCATION (orig_stmt), orig_stmt, orig_stmt, true, &rank)) @@ -1213,6 +1226,12 @@ expand_array_notation_exprs (tree t) if (TREE_OPERAND (t, 0) == error_mark_node) return TREE_OPERAND (t, 0); return t; + case TRUTH_ANDIF_EXPR: + case TRUTH_ORIF_EXPR: + case TRUTH_AND_EXPR: + case TRUTH_OR_EXPR: + case TRUTH_XOR_EXPR: + case TRUTH_NOT_EXPR: case COND_EXPR: t = cp_expand_cond_array_notations (t); if (TREE_CODE (t) == COND_EXPR) @@ -1222,8 +1241,6 @@ expand_array_notation_exprs (tree t) COND_EXPR_ELSE (t) = expand_array_notation_exprs (COND_EXPR_ELSE (t)); } - else - t = expand_array_notation_exprs (t); return t; case FOR_STMT: if (contains_array_notation_expr (FOR_COND (t))) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e09c325..ba5286f 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3954,6 +3954,20 @@ cp_build_binary_op (location_t location, type0 = TREE_TYPE (op0); type1 = TREE_TYPE (op1); + /* If it is a built-in array notation function, then the return type of + the function is the type of the array passed in as array notation. */ + if (flag_enable_cilkplus && TREE_CODE (op1) == CALL_EXPR + && is_cilkplus_reduce_builtin (CALL_EXPR_FN (op1))) + { + tree array_ntn = CALL_EXPR_ARG (op1, 0); + type1 = TREE_TYPE (array_ntn); + } + if (flag_enable_cilkplus && TREE_CODE (op0) == CALL_EXPR + && is_cilkplus_reduce_builtin (CALL_EXPR_FN (op0))) + { + tree array_ntn = CALL_EXPR_ARG (op0, 0); + type0 = TREE_TYPE (array_ntn); + } /* The expression codes of the data types of the arguments tell us whether the arguments are integers, floating, pointers, etc. */ code0 = TREE_CODE (type0); diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57490.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57490.c new file mode 100644 index 0000000..db38b30 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57490.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +const int n = 8; +float x[8], y[8], z[8]; +int main() { + int i = 0; + float x_sum =0; + for(i=1; i<=5; i+=4 ) { + x[0:n] = 3; + y[0:n] = i; + z[0:n] = 0; + (void)((__sec_reduce_add(x[0:n])==3*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(y[0:n])==i*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(z[0:n])==0) || (__builtin_abort (), 0)); + + if (x[0:n] >= y[0:n]) { + z[0:n] = x[0:n] - y[0:n]; + } else { + z[0:n] = x[0:n] + y[0:n]; + } + (void)((__sec_reduce_add(x[0:n])==3*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(y[0:n])==i*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(z[0:n])==(3>=i?3-i:3+i)*n) + || (__builtin_abort (), 0)); + } + return 0; +}