From patchwork Wed Sep 15 13:20:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 64814 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 50F3DB6F06 for ; Wed, 15 Sep 2010 23:21:09 +1000 (EST) Received: (qmail 13767 invoked by alias); 15 Sep 2010 13:21:06 -0000 Received: (qmail 13751 invoked by uid 22791); 15 Sep 2010 13:21:04 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Wed, 15 Sep 2010 13:20:40 +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 F1F408E8CC for ; Wed, 15 Sep 2010 15:20:37 +0200 (CEST) Date: Wed, 15 Sep 2010 15:20:37 +0200 From: Martin Jambor To: GCC Patches Cc: Richard Guenther Subject: [PATCH, IPA-SRA] Fix PR 45644 Message-ID: <20100915132034.GA9347@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, IPA-SRA was never meant to handle bit-fields (because of even more unclear cost considerations) and so I did not bother to make the call statement modification work with them and with the new MEM_REF implementation it doesn't. However, the detection condition is wrong and fails to catch some cases. Becase it is at a place where BIT_FIELD_REFs do not get, I changed it to look at the field declaration directly, just as we do in build_ref_for_model. This fixes 450.soplex (at least the test run, I'm running a reference run now) and I have bootstrapped and tested it without any issues on x86_64-linux. OK for trunk? Thanks, Martin 2010-09-14 Martin Jambor PR middle-end/45644 * tree-sra.c (create_access): Check for bit-fields directly. * testsuite/gcc.dg/ipa/pr45644.c: New test. Index: mine/gcc/tree-sra.c =================================================================== --- mine.orig/gcc/tree-sra.c +++ mine/gcc/tree-sra.c @@ -774,12 +774,13 @@ create_access (tree expr, gimple stmt, b disqualify_candidate (base, "Encountered a variable sized access."); return NULL; } - if ((offset % BITS_PER_UNIT) != 0 || (size % BITS_PER_UNIT) != 0) + if (TREE_CODE (expr) == COMPONENT_REF + && DECL_BIT_FIELD (TREE_OPERAND (expr, 1))) { - disqualify_candidate (base, - "Encountered an acces not aligned to a byte."); + disqualify_candidate (base, "Encountered a bit-field access."); return NULL; } + gcc_checking_assert ((offset % BITS_PER_UNIT) == 0); if (ptr) mark_parm_dereference (base, offset + size, stmt); Index: mine/gcc/testsuite/gcc.dg/ipa/pr45644.c =================================================================== --- /dev/null +++ mine/gcc/testsuite/gcc.dg/ipa/pr45644.c @@ -0,0 +1,35 @@ +/* Verify that we do not IPA-SRA bitfields. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +struct S +{ + int j : 8; + int i : 24; + int l; +}; + +static int __attribute__((noinline)) foo (struct S *s) +{ + int z = s->i; + if (z != 777) + abort (); + return 0; +} + +int __attribute__((noinline)) bar (struct S *s) +{ + return foo (s); +} + +int main (int argc, char *argv[]) +{ + struct S s; + s.j = 5; + s.i = 777; + s.l = -1; + + return bar (&s); +}