From patchwork Wed Dec 29 00:06:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 76874 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 C016FB70E2 for ; Wed, 29 Dec 2010 11:05:52 +1100 (EST) Received: (qmail 5900 invoked by alias); 29 Dec 2010 00:05:47 -0000 Received: (qmail 5888 invoked by uid 22791); 29 Dec 2010 00:05:45 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00 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; Wed, 29 Dec 2010 00:05:40 +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 402F28E8CC for ; Wed, 29 Dec 2010 01:05:38 +0100 (CET) Date: Wed, 29 Dec 2010 01:06:35 +0100 From: Martin Jambor To: GCC Patches Cc: Richard Guenther Subject: [PATCH, PR 46801] Allow byte-aligned aggregate bit-fields in SRA Message-ID: <20101229000635.GA31120@alvy.suse.cz> 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, PR 46801 tests for an optimization that is not carried out because SRA currently does not even consider stuff with an aggregate bit-field in them. However, the screening of candidates can be made a bit more permissive because problems are caused by aggregate fields that are not byte-aligned, not by just any aggregate field with the bit-field flag set. And that is what the patch below does. Bootstrapped and tested on x86_64-linux without any problems. OK for trunk? Thanks, Martin 2010-12-28 Martin Jambor PR tree-optimization/46801 * tree-sra.c (type_internals_preclude_sra_p): Check whether aggregate fields start at byte boundary instead of the bit-field flag. * testsuite/gnat.dg/pack9.adb: Remove xfail. Index: mine/gcc/testsuite/gnat.dg/pack9.adb =================================================================== --- mine.orig/gcc/testsuite/gnat.dg/pack9.adb 2010-12-28 23:35:28.000000000 +0100 +++ mine/gcc/testsuite/gnat.dg/pack9.adb 2010-12-28 23:35:30.000000000 +0100 @@ -15,5 +15,5 @@ package body Pack9 is end Pack9; --- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" { xfail *-*-* } } } +-- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" } } -- { dg-final { cleanup-tree-dump "optimized" } } Index: mine/gcc/tree-sra.c =================================================================== --- mine.orig/gcc/tree-sra.c 2010-12-28 23:29:36.000000000 +0100 +++ mine/gcc/tree-sra.c 2010-12-28 23:30:56.000000000 +0100 @@ -653,7 +653,8 @@ type_internals_preclude_sra_p (tree type || !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld) || !host_integerp (DECL_FIELD_OFFSET (fld), 1) || !host_integerp (DECL_SIZE (fld), 1) - || (DECL_BIT_FIELD (fld) && AGGREGATE_TYPE_P (ft))) + || (AGGREGATE_TYPE_P (ft) + && int_bit_position (fld) % BITS_PER_UNIT != 0)) return true; if (AGGREGATE_TYPE_P (ft)