From patchwork Wed Oct 3 20:09:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 188897 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]) by ozlabs.org (Postfix) with SMTP id 66A2C2C0086 for ; Thu, 4 Oct 2012 06:09:41 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1349899781; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=favfnFqUfkqJ9SOahqWlPcwlANI=; b=k3mocAB9N7ahVqVstGAQ8FmPhsU/dOVdSn6HOFsRq0n7rYZx3NU753+vpFRtMk jFrfLlurZxsn7QwoKHJuJRCBQj/zyowIKAKwV55Wg5N6K2Tb/u3Rqnw94g9ylzHV TAKExvwppCQNCdK5cezPrsQ7l2j5A+Nq//YFHEENBOZEY= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-System-Of-Record:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=JwinTKzYyRJXpZr3BB4FftU4EE2eF57uhQG8EZuzs1Iq9itGtQE5iT+ppTC0oi eMvroPdVobox3LBU/GmcBFxaUzfdyf/62SF07c6tGMIV74HyYQCt/J55ddupUpIK U0RqLZe2Hh6rr46K0YqdihgDlYAmOR/AAzJS2VGJPn1/0=; Received: (qmail 24137 invoked by alias); 3 Oct 2012 20:09:34 -0000 Received: (qmail 24120 invoked by uid 22791); 3 Oct 2012 20:09:33 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-da0-f47.google.com (HELO mail-da0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Oct 2012 20:09:28 +0000 Received: by daks35 with SMTP id s35so2609041dak.20 for ; Wed, 03 Oct 2012 13:09:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-system-of-record:x-gm-message-state; bh=5WI3Ak3+RGJVTf5k7WaWO6OnmOhn2puybgadKVdNUVY=; b=U+oidffzl8XPaWk60NJqfi4M3OZSxc1ck3b9s7Ua+w4PzMd6L8HqL19bBpw1cQAsGy CYARbuIqoKtBgBr1wegJKTz5gdz7QDSH1nmvymnUzyD8VsI0cMMDHyedugbQg0ZXsZL9 AMlrM4BeNQNioFAmn1PwilBpw65PuJbz+4YbGY3Ln25oVKxvsGDqIrb77K1aadZvvCER AsJlPiPp3uPY+o1MegJJAXZgOv8tk9Fp/9LN7om1Ro16HR2KA0FJRsWA2uSYCSHKGNqI HQY9yYYPkJSGCtGTho2ZB/E2uXG7oVP/qGy4azWZmqylnmFBKnMIsz9ND12JYW0U590e WeRA== MIME-Version: 1.0 Received: by 10.68.138.170 with SMTP id qr10mr15634699pbb.53.1349294967950; Wed, 03 Oct 2012 13:09:27 -0700 (PDT) Received: by 10.68.49.232 with HTTP; Wed, 3 Oct 2012 13:09:27 -0700 (PDT) In-Reply-To: <20121003184650.GV1787@tucnak.redhat.com> References: <20121003184650.GV1787@tucnak.redhat.com> Date: Wed, 3 Oct 2012 13:09:27 -0700 Message-ID: Subject: Re: [PATCH] Fix PR54782 From: Dehao Chen To: Jakub Jelinek Cc: GCC Patches X-System-Of-Record: true X-Gm-Message-State: ALoCoQkbL7l6N4rxwFfE0EdxhuNKxOuvfvgrLNyiJ7z1dUmDA1umOVxOYylIGbuDz4ZgrPu6sSZnUevPQCbUBttC7j1bdJgEYAY9JFRY19x4iaAErhaHG7ycmmtMLD/Y7vhFYBcjFBPmN728vJPwZm2+/b+SLV4MSEc1nutsyZtLrWX00dyTNzlnWQ9jgDn0+YgOF4y1wOkE X-IsSubscribed: yes 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 Thanks for the comments. The patch was updated as attached. Dehao On Wed, Oct 3, 2012 at 11:46 AM, Jakub Jelinek wrote: > On Wed, Oct 03, 2012 at 11:26:09AM -0700, Dehao Chen wrote: >> @@ -6340,6 +6341,20 @@ move_block_to_fn (struct function *dest_cfun, basi >> SET_USE (use, replace_ssa_name (op, d->vars_map, dest_cfun->decl)); >> } >> >> + for (i = 0; i < EDGE_COUNT (bb->preds); i++) >> + { >> + location_t locus = gimple_phi_arg_location (phi, i); >> + if (locus != UNKNOWN_LOCATION) >> + { >> + tree block = LOCATION_BLOCK (locus); >> + if (d->orig_block == NULL_TREE > || block == d->orig_block) >> + gimple_phi_arg_set_location (phi, i, d->new_block ? >> + COMBINE_LOCATION_DATA (line_table, locus, d->new_block) : >> + LOCATION_LOCUS (locus)); >> + } >> + } >> + > > The formatting is wrong on this. ? and : would need to go to the next line > and even the indentation of part of an argument is weird. > IMHO better just do: > if (d->orig_block == NULL_TREE || block == d->orig_block) > { > if (d->new_block) > locus = COMBINE_LOCATION_DATA (line_table, locus, > d->new_block); > else > locus = LOCATION_LOCUS (locus); > gimple_phi_arg_set_location (phi, i, locus); > } > > It will be far more readable. > And/or to decrease indentation level you could do > if (locus == UNKNOWN_LOCATION) > continue; > block = LOCATION_BLOCK (locus); > ... > > Jakub Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 192041) +++ gcc/tree-cfg.c (working copy) @@ -6322,6 +6322,7 @@ move_block_to_fn (struct function *dest_cfun, basi use_operand_p use; tree op = PHI_RESULT (phi); ssa_op_iter oi; + unsigned i; if (virtual_operand_p (op)) { @@ -6340,6 +6341,23 @@ move_block_to_fn (struct function *dest_cfun, basi SET_USE (use, replace_ssa_name (op, d->vars_map, dest_cfun->decl)); } + for (i = 0; i < EDGE_COUNT (bb->preds); i++) + { + location_t locus = gimple_phi_arg_location (phi, i); + tree block = LOCATION_BLOCK (locus); + + if (locus == UNKNOWN_LOCATION) + continue; + if (d->orig_block == NULL_TREE || block == d->orig_block) + { + if (d->new_block == NULL_TREE) + locus = LOCATION_LOCUS (locus); + else + locus = COMBINE_LOCATION_DATA (line_table, locus, d->new_block); + gimple_phi_arg_set_location (phi, i, locus); + } + } + gsi_next (&si); } Index: gcc/testsuite/gcc.dg/pr54782.c =================================================================== --- gcc/testsuite/gcc.dg/pr54782.c (revision 0) +++ gcc/testsuite/gcc.dg/pr54782.c (revision 0) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -ftree-parallelize-loops=2 -g" } */ + +struct S +{ + int n; + float *a; +}; + +int +foo (struct S *s) +{ + float sum = 0; + int i; + for (i = 0; i < s->n; i++) + sum += s->a[i]; + return sum; +}