From patchwork Tue Jan 15 14:50:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 212200 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 CA2F22C00A5 for ; Wed, 16 Jan 2013 01:51:01 +1100 (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=1358866262; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:In-Reply-To:Message-ID:References:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=o8zgDyrR8ZK++F79+n4orWJbSVA=; b=ifIgQEXuKt21Bwo vWry7NfD3bosXMAlADnys936UuPgTvpFAuDcGuDHCMqedxOKr/w1nbgCxFrvgN/x w0cS3t1SYdd3dPwPVJ3q8wywgJCwFz2a87Na06lNz0SG85XcbUoQSltSVYsOd/eM oxNke6Qp9wAlrNgS2tbd/MUkG/CY= 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:Date:From:To:Cc:Subject:In-Reply-To:Message-ID:References:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=x8ryj/94VpZJYZp1zONeCjaBkTwI60zEuEA//Szr6HWDtakQEFr/hI88wLlKxZ azaxN7yrlOzmYfK8cvenaxb9HYQcED6LOaXJTQkVlViKojMb6B7Fc0MKSiny1Uau eMZ887iHB0iXxj3U/qQ43THcr5hfUCguLoHDA9h3/8UcY=; Received: (qmail 28165 invoked by alias); 15 Jan 2013 14:50:50 -0000 Received: (qmail 28144 invoked by uid 22791); 15 Jan 2013 14:50:48 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Jan 2013 14:50:38 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id CEBF2A5208; Tue, 15 Jan 2013 15:50:36 +0100 (CET) Date: Tue, 15 Jan 2013 15:50:36 +0100 (CET) From: Richard Biener To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org, Michael Matz Subject: Re: [PATCH] Fix PR55882 In-Reply-To: <1366843.hbPgaJ0q9u@polaris> Message-ID: References: <1366843.hbPgaJ0q9u@polaris> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 On Tue, 15 Jan 2013, Eric Botcazou wrote: > > I have applied the minimal fix to trunk now. We retain the clearly > > incorrect fact that the !align_computed path only ever increases > > alignment (it's only ever set previously to either BITS_PER_UNIT > > or via the MEM_REF block). I will momentarily test a followup > > removing that block for trunk. > > What do we do for the 4.7 branch? The patch doesn't compile for it so I > presume that there are one or more changes to be backported first? Not necessarily. The following is a 4.7 variant of the patch (on trunk get_object_alignment_1 got one extra output which moved the align return value to by-reference). Can you give it testing on the branch and a strict-align target? Thanks, Richard. 2013-01-15 Richard Biener PR middle-end/55882 * emit-rtl.c (set_mem_attributes_minus_bitpos): Correctly account for bitpos when computing alignment. * gcc.dg/torture/pr55882.c: New testcase. Index: gcc/testsuite/gcc.dg/torture/pr55882.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr55882.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr55882.c (working copy) *************** *** 0 **** --- 1,94 ---- + /* { dg-do run } */ + + typedef enum + { + PVT_A = 0, + PVT_B = 1, + PVT_CONFIG = 2, + PVT_RESERVED3 = 3, + } T_CR_SELECT; + + typedef enum + { + STD_ULOGIC_0 = 0, + STD_ULOGIC_1 = 1, + } STD_ULOGIC; + + typedef struct + { + unsigned char rtp : 3; + unsigned char rtn : 3; + } C; + + typedef struct + { + unsigned char nd; + unsigned char pd; + unsigned char rtn; + unsigned char rtp; + } A; + + typedef struct + { + unsigned short reserved : 14; + unsigned char Z_rx_enable : 2; + A pvt; + } B; + + typedef struct + { + B cr_dsclk_q3; + B cr_data_q3; + B cr_addr_q3; + B cr_cmd_q3; + B cr_pres_q3; + C cr_vref_q3[6]; + unsigned char pres_disable; + unsigned char pres_drive_high; + unsigned char c_enab_120; + STD_ULOGIC clk_tximp; + STD_ULOGIC dqs_tximp; + STD_ULOGIC cmd_tximp; + STD_ULOGIC data_tximp; + STD_ULOGIC dqs_rxterm; + STD_ULOGIC data_rxterm; + T_CR_SELECT cr_clk_sel; + unsigned char cr_clk : 5; + T_CR_SELECT cr_dsclk_odd_sel; + unsigned char cr_dsclk_odd : 5; + T_CR_SELECT cr_dsclk_even_sel; + unsigned char cr_dsclk_even : 5; + T_CR_SELECT cr_data_sel; + unsigned char cr_data : 5; + T_CR_SELECT cr_vref_sel; + unsigned char cr_vref : 5; + T_CR_SELECT cr_others_sel; + unsigned char cr_others : 5; + } CONFIG; + + typedef struct + { + unsigned char enable_monitor; + unsigned short step_out_pointer : 12; + unsigned short hold_out_pointer : 12; + unsigned short enable_wr_dqs : 12; + unsigned short use_alt_rd_dqs : 12; + CONFIG io_buf; + } mystruct; + + unsigned short __attribute__((noinline,noclone)) + testfunction(unsigned i) + { + mystruct dmfe[8]; + dmfe[0].use_alt_rd_dqs = 1; + dmfe[i].use_alt_rd_dqs = 0; + return dmfe[0].use_alt_rd_dqs; + } + + extern void abort (void); + int main () + { + if (testfunction(0) != 0) + abort (); + return 0; + } Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c (revision 195201) +++ gcc/emit-rtl.c (working copy) @@ -1839,7 +1839,12 @@ set_mem_attributes_minus_bitpos (rtx ref if (!align_computed) { - unsigned int obj_align = get_object_alignment (t); + unsigned int obj_align; + unsigned HOST_WIDE_INT obj_bitpos; + obj_align = get_object_alignment_1 (t, &obj_bitpos); + obj_bitpos = (obj_bitpos - bitpos) & (obj_align - 1); + if (obj_bitpos != 0) + obj_align = (obj_bitpos & -obj_bitpos); attrs.align = MAX (attrs.align, obj_align); } }