From patchwork Thu Jan 27 12:46:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 80670 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 91CF3B7133 for ; Thu, 27 Jan 2011 23:47:06 +1100 (EST) Received: (qmail 22520 invoked by alias); 27 Jan 2011 12:47:02 -0000 Received: (qmail 22510 invoked by uid 22791); 27 Jan 2011 12:47:01 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Jan 2011 12:46:56 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id A2F7090975 for ; Thu, 27 Jan 2011 13:46:53 +0100 (CET) Date: Thu, 27 Jan 2011 13:46:53 +0100 From: Martin Jambor To: GCC Patches Cc: Richard Guenther Subject: [PR 47228] Use build_ref_for_model instead of build_ref_for_offset Message-ID: <20110127124653.GA8864@virgil.arch.suse.de> Mail-Followup-To: GCC Patches , Richard Guenther MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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, at two points I kept a call to build_ref_for_offset in tree-sra.c instead of converting them to build_ref_for_model like all the others. There was a reason for this but I cannot recall what exactly it was, except that it would have been useless before Eric's change to build_ref_for_model. Nevertheless, after that change build_ref_for_model can help us avoid PR 47228. So this patch converts these two calls too. I have bootstrapped and tested this on x86_64-linux and I have also ran testsuite of c and c++ on i686 without any issues. OK for trunk? Thanks, Martin 2011-01-26 Martin Jambor PR tree-optimization/47228 * tree-sra.c (sra_modify_assign): Use build_ref_for_model instead of build_ref_for_offset. * testsuite/gcc.dg/torture/pr47228.c: New test. Index: src/gcc/testsuite/gcc.dg/torture/pr47228.c =================================================================== --- /dev/null +++ src/gcc/testsuite/gcc.dg/torture/pr47228.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +struct S4 +{ + unsigned f0:24; +} __attribute__((__packed__)); + +struct S4 g_10 = { + 6210831 +}; + +struct S4 func_2 (int x) +{ + struct S4 l_8[2] = { + {0}, {0} + }; + g_10 = l_8[1]; + for (; x<2; x++) { + struct S4 tmp = { + 11936567 + }; + l_8[x] = tmp; + } + return g_10; +} + +int main (void) +{ + func_2 (0); + return 0; +} Index: src/gcc/tree-sra.c =================================================================== --- src.orig/gcc/tree-sra.c +++ src/gcc/tree-sra.c @@ -2739,15 +2739,13 @@ sra_modify_assign (gimple *stmt, gimple_ && !contains_bitfld_comp_ref_p (lhs) && !access_has_children_p (lacc)) { - lhs = build_ref_for_offset (loc, lhs, 0, TREE_TYPE (rhs), - gsi, false); + lhs = build_ref_for_model (loc, lhs, 0, racc, gsi, false); gimple_assign_set_lhs (*stmt, lhs); } else if (AGGREGATE_TYPE_P (TREE_TYPE (rhs)) && !contains_vce_or_bfcref_p (rhs) && !access_has_children_p (racc)) - rhs = build_ref_for_offset (loc, rhs, 0, TREE_TYPE (lhs), - gsi, false); + rhs = build_ref_for_model (loc, rhs, 0, lacc, gsi, false); if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) {