From patchwork Wed Oct 3 18:26:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 188891 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 636582C0141 for ; Thu, 4 Oct 2012 04:26:18 +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=1349893578; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=4bTtKBa 6h9aaaiguvpXds6SsXsc=; b=Eorko9vIGU6Bl/T92nVyKEVakskLaNaD7Lgg4CY Oq5vYxg1jflLN3vEW5obO8K95r2WZZJ32HLAY7fc/qShLOGrXQqtvNCfwt1udxXb Qr6WB0kNJNmSj6TObrK9Vx56+4bT2Ag7GGsNW8FWEBGuNkQUC3cNg+rkNnVcWa0p z710= 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:Date:Message-ID:Subject:From:To: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=Kl7gC97SKVXyMI3nvKAWext81tcENQ0VFprxRKHqxHkXcTvDzke6Q5m7YrktfJ BufVja8PQ7WoiJDFMjgxTtbypVWP/LbQ6FmvSXV03qX4SfCMRPuSkAjUGTKYr5la YoADicfTn+58gyUA+CJ1o+Ods1f8N5x6q77rEWuMG/ZS8=; Received: (qmail 3010 invoked by alias); 3 Oct 2012 18:26:15 -0000 Received: (qmail 3002 invoked by uid 22791); 3 Oct 2012 18:26:14 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Oct 2012 18:26:09 +0000 Received: by padfa11 with SMTP id fa11so6893090pad.20 for ; Wed, 03 Oct 2012 11:26:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-system-of-record:x-gm-message-state; bh=Eyt2Ln6Hv5OLdH+C4V28taQz4+5ivE9rHa6kInED7lI=; b=ldqc5MwEYBYBKW+myLtQYbl9iOzFQJ0k50eCd+3aSI+fHzfGkAhf3IlqHTy/44Btcg U2lD76Xyv5ZTWA2rwcsdLNOeCMZASsifn8ggNpWdozDZDgU3sNOz+/LeyGKPOclpz/yQ K5wnq8g8zenwhcqyhJeAYW/NhZq7LPTZEWYTbNhiZ4n6/O0GTHdSo0vPq7oriaSz5zo+ xUBcFvzb0kavHes9bPkHBo7zGB6hzHbyTJARgjO0ECkQlEdOQ1IIDZj9imrlLqnaH5+1 rBsQLIfcT36nOxWgrYbYhQaHTiMIhZQMtWmXhwvNZFa6fXoApGUNqRVWkfXVqOAdYsD7 CvRQ== MIME-Version: 1.0 Received: by 10.68.138.170 with SMTP id qr10mr15021830pbb.53.1349288769220; Wed, 03 Oct 2012 11:26:09 -0700 (PDT) Received: by 10.68.49.232 with HTTP; Wed, 3 Oct 2012 11:26:09 -0700 (PDT) Date: Wed, 3 Oct 2012 11:26:09 -0700 Message-ID: Subject: [PATCH] Fix PR54782 From: Dehao Chen To: GCC Patches X-System-Of-Record: true X-Gm-Message-State: ALoCoQnBm2VbIWEPnsOeOQq9RxJXBYdSkllN1+igbv8lIc0/bcWNzJJSgcavhmNtWLO/ni1+RnfAllm4MhCex5/CFNBvZzbeMFSttHrDfmtFfqwagCjcfrdybS/88mE6HtVgS97wv35rHfjo2Hf0y8oG6BSm2NnFCrx89axQbXUdo96lFiuoou9Ii83kGQgOdjLXrR1ZV1v5 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 Hi, Attached patch fixes PR54782. phi_arg_location is not correctly updated in move_block_to_fn. This patch fixes the problem. Bootstrapped and passed gcc regression tests on x86. Okay for trunk? Thanks, Dehao gcc/ChangeLog: 2012-10-03 Dehao Chen PR middle-end/54782 * tree-cfg.c (move_block_to_fn): Update lexical block for phi_args. gcc/testsuite/ChangeLog: 2012-10-03 Dehao Chen PR middle-end/54782 * gcc.dg/pr54782.c: New test. 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,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)); + } + } + 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; +}