From patchwork Mon Nov 4 15:19:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 288196 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DC69D2C00D1 for ; Tue, 5 Nov 2013 02:21:34 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=SUHo22P//oBGg0Shbw4lNdnfl0U/KR3QoJyuWtEfLrQMd/ fUX7KQQXybkoc5+NuzzhAupfusagdDP7FMV/qQ1Ebxm9KCYMWv8073EhxT986vgC 6uf+lY/C1TdhDRPhJW4FG0GUkqg9ewLKo42f4sT4YKcCekxDEhRu2iyINQ/9M= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=RqO5qLxv1upi1wgpgs9H6qu6Ih8=; b=hr9CnxEX7Rniv3VutPwX t1Bs3tCUq1K78KRWVPl1LsSSuhF4WnFtHuWLrxC7wRzBtVojwZf3gqeaJwxlCNks DJ0CPoYjwSvUmNgp4bNAijmEBdC7hAoPqDtiCRT/3AP9bfAAH4DscX6AVInWJZyI Vhi79lWb5uS/qO1bbBLUpXU= Received: (qmail 31150 invoked by alias); 4 Nov 2013 15:21:24 -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 31137 invoked by uid 89); 4 Nov 2013 15:21:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_05, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Nov 2013 15:19:18 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA4FJDxG002176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Nov 2013 10:19:13 -0500 Received: from reynosa.quesejoda.com (vpn-50-49.rdu2.redhat.com [10.10.50.49]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rA4FJCO7016813; Mon, 4 Nov 2013 10:19:13 -0500 Message-ID: <5277BAF0.6050506@redhat.com> Date: Mon, 04 Nov 2013 08:19:12 -0700 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Jakub Jelinek , gcc-patches Subject: [omp4] Hi. While looking over some of your testcases I noticed that array subscripts are not being properly adjusted: foo(int i) { array[i] = .... } The `i' should use the simd array magic instead of ICEing :). Is the attached patch OK for the branch? Aldy gcc/ChangeLog.gomp * omp-low.c (ipa_simd_modify_function_body): Adjust tree operands on the LHS of an assign. (ipa_simd_modify_function_body_ops_1): New. (ipa_simd_modify_function_body_ops): New. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index d30fb17..94058af 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -11049,6 +11049,35 @@ simd_clone_init_simd_arrays (struct cgraph_node *node, return seq; } +static tree +ipa_simd_modify_function_body_ops_1 (tree *tp, int *walk_subtrees, void *data) +{ + struct walk_stmt_info *wi = (struct walk_stmt_info *) data; + ipa_parm_adjustment_vec *adjustments = (ipa_parm_adjustment_vec *) wi->info; + tree t = *tp; + + if (DECL_P (t) || TREE_CODE (t) == SSA_NAME) + return (tree) sra_ipa_modify_expr (tp, true, *adjustments); + else + *walk_subtrees = 1; + return NULL_TREE; +} + +/* Helper function for ipa_simd_modify_function_body. Make any + necessary adjustments for tree operators. */ + +static bool +ipa_simd_modify_function_body_ops (tree *tp, + ipa_parm_adjustment_vec *adjustments) +{ + struct walk_stmt_info wi; + memset (&wi, 0, sizeof (wi)); + wi.info = adjustments; + bool res = (bool) walk_tree (tp, ipa_simd_modify_function_body_ops_1, + &wi, NULL); + return res; +} + /* Traverse the function body and perform all modifications as described in ADJUSTMENTS. At function return, ADJUSTMENTS will be modified such that the replacement/reduction value will now be an @@ -11121,6 +11150,11 @@ ipa_simd_modify_function_body (struct cgraph_node *node, case GIMPLE_ASSIGN: t = gimple_assign_lhs_ptr (stmt); modified |= sra_ipa_modify_expr (t, false, adjustments); + + /* The LHS may have operands that also need adjusting + (e.g. `foo' in array[foo]). */ + modified |= ipa_simd_modify_function_body_ops (t, &adjustments); + for (i = 0; i < gimple_num_ops (stmt); ++i) { t = gimple_op_ptr (stmt, i); diff --git a/gcc/testsuite/gcc.dg/gomp/simd-clones-6.c b/gcc/testsuite/gcc.dg/gomp/simd-clones-6.c new file mode 100644 index 0000000..8818594 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/simd-clones-6.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fopenmp" } */ + +/* Test that array subscripts are properly adjusted. */ + +int array[1000]; +#pragma omp declare simd notinbranch simdlen(4) +void foo (int i) +{ + array[i] = 555; +}