From patchwork Mon Aug 2 15:49:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 60550 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 D7FF6B6EF0 for ; Tue, 3 Aug 2010 01:49:23 +1000 (EST) Received: (qmail 16297 invoked by alias); 2 Aug 2010 15:49:20 -0000 Received: (qmail 16260 invoked by uid 22791); 2 Aug 2010 15:49:17 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, TW_TM 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; Mon, 02 Aug 2010 15:49:13 +0000 Received: from relay1.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 1A6CC94393 for ; Mon, 2 Aug 2010 17:49:11 +0200 (CEST) Date: Mon, 2 Aug 2010 17:49:10 +0200 From: Martin Jambor To: GCC Patches Cc: Richard Guenther Subject: [PATCH] Let completely_scalarize_record creates access expressions on its own Message-ID: <20100802154910.GA18246@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, this is a first patch in a small series to make build_ref_for offset build a MEM_REF instead of the elaborate recursive algorithm we have there today (and as a by-product, fix PR44972). This patch addresses the problem that we do not want MEM_REFs in DECL_DEBUG_EXPRs and so cannot really store such references to access->expr fields. Thus instead of relying on build_ref_for_offset to create the references for us, I taught the function to easily create them itself. BTW, I'm afraid that we'll need to retain the current elaborate build_ref_for_offset, perhaps under a different name, to create these references in create_artificial_child_access. Also, for the currently WIP re-implementation of build_ref_for_offset I simply need it for bit-fields :-) And last but not least, this is a much more straight-forward way of doing things and so perhaps also worht to have on its own. Bootstrapped and tested on x86_85-linux, OK for trunk? Thanks, Martin 2010-07-29 Martin Jambor * tree-sra.c (completely_scalarize_record): New parameter REF, create its own access->expr intead of using build_ref_for_offset. Index: mine/gcc/tree-sra.c =================================================================== --- mine.orig/gcc/tree-sra.c +++ mine/gcc/tree-sra.c @@ -843,10 +843,12 @@ type_consists_of_records_p (tree type) /* Create total_scalarization accesses for all scalar type fields in DECL that must be of a RECORD_TYPE conforming to type_consists_of_records_p. BASE must be the top-most VAR_DECL representing the variable, OFFSET must be the - offset of DECL within BASE. */ + offset of DECL within BASE. REF must be the memory reference expression for + the given decl. */ static void -completely_scalarize_record (tree base, tree decl, HOST_WIDE_INT offset) +completely_scalarize_record (tree base, tree decl, HOST_WIDE_INT offset, + tree ref) { tree fld, decl_type = TREE_TYPE (decl); @@ -855,28 +857,23 @@ completely_scalarize_record (tree base, { HOST_WIDE_INT pos = offset + int_bit_position (fld); tree ft = TREE_TYPE (fld); + tree nref = build3 (COMPONENT_REF, TREE_TYPE (fld), ref, fld, + NULL_TREE); if (is_gimple_reg_type (ft)) { struct access *access; HOST_WIDE_INT size; - tree expr; - bool ok; size = tree_low_cst (DECL_SIZE (fld), 1); - expr = base; - ok = build_ref_for_offset (&expr, TREE_TYPE (base), pos, - ft, false); - gcc_assert (ok); - access = create_access_1 (base, pos, size); - access->expr = expr; + access->expr = nref; access->type = ft; access->total_scalarization = 1; /* Accesses for intraprocedural SRA can have their stmt NULL. */ } else - completely_scalarize_record (base, fld, pos); + completely_scalarize_record (base, fld, pos, nref); } } @@ -2067,7 +2064,7 @@ analyze_all_variable_accesses (void) <= max_total_scalarization_size) && type_consists_of_records_p (TREE_TYPE (var))) { - completely_scalarize_record (var, var, 0); + completely_scalarize_record (var, var, 0, var); if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Will attempt to totally scalarize ");