From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1551 invoked by alias); 8 Jan 2013 15:47:40 -0000 Received: (qmail 1494 invoked by uid 48); 8 Jan 2013 15:47:12 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/55882] unaligned load/store : incorrect struct offset Date: Tue, 08 Jan 2013 15:47:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00663.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55882 --- Comment #7 from Richard Biener 2013-01-08 15:47:10 UTC --- Ok with respect to alignment the issue is that when we expand_assignment for to == dmfe[i_1].use_alt_rd_dqs we fall into the old trap for STRICT_ALIGNMENT targets to use the mode alignment. That's because we fall into misalignp = false; to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_WRITE); which creates (mem/c:BLK (plus:SI (reg/f:SI 189 virtual-stack-vars) (const_int 4 [0x4])) [0 dmfe+0 S992 A32]) as dmfe is 4-byte aligned. With offset = (sizetype) i_1 * 124 + 2 and bitregion_start = 0, bitregion_end = 63, bitpos = 48 and after adjusting the offset we feed (mem/c:BLK (plus:SI (reg/f:SI 206) (const_int 6 [0x6])) [0 dmfe A16]) into set_mem_attributes_minus_bitpos (with bitpos == 48) and get_object_alignment returns 32. But we fail to consider bitpos when using that alignment. So ... does the following patch fix it for you? Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c (revision 195014) +++ gcc/emit-rtl.c (working copy) @@ -1839,7 +1839,13 @@ 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; + get_object_alignment_1 (t, &obj_align, &obj_bitpos); + if (apply_bitpos) + obj_bitpos += apply_bitpos; + if (obj_bitpos != 0) + obj_align = (obj_bitpos & -obj_bitpos); attrs.align = MAX (attrs.align, obj_align); } }