From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3835 invoked by alias); 19 Jul 2012 13:36:50 -0000 Received: (qmail 3708 invoked by uid 22791); 19 Jul 2012 13:36:49 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 Jul 2012 13:36:36 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/54031] [4.8 Regression] Revision 189607 miscompiles Linux kernel Date: Thu, 19 Jul 2012 13:36:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization 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: 4.8.0 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: 2012-07/txt/msg01494.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54031 --- Comment #2 from Richard Guenther 2012-07-19 13:36:34 UTC --- I have spotted an error in the patch, can you try Index: gcc/builtins.c =================================================================== --- gcc/builtins.c (revision 189656) +++ gcc/builtins.c (working copy) @@ -346,12 +346,10 @@ get_object_alignment_2 (tree exp, unsign known_alignment = get_pointer_alignment_1 (addr, &ptr_align, &ptr_bitpos); - bitpos += ptr_bitpos; align = MAX (ptr_align, align); - if (TREE_CODE (exp) == MEM_REF - || TREE_CODE (exp) == TARGET_MEM_REF) - bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT; + /* The alignment of the pointer operand in a TARGET_MEM_REF + has to take the variable offset parts into account. */ if (TREE_CODE (exp) == TARGET_MEM_REF) { if (TMR_INDEX (exp)) @@ -369,9 +367,19 @@ get_object_alignment_2 (tree exp, unsign /* When EXP is an actual memory reference then we can use TYPE_ALIGN of a pointer indirection to derive alignment. Do so only if get_pointer_alignment_1 did not reveal absolute - alignment knowledge. */ - if (!addr_p && !known_alignment) - align = MAX (TYPE_ALIGN (TREE_TYPE (exp)), align); + alignment knowledge and if using that alignment would + improve the situation. */ + if (!addr_p && !known_alignment + && TYPE_ALIGN (TREE_TYPE (exp)) > align) + align = TYPE_ALIGN (TREE_TYPE (exp)); + else + { + /* Else adjust bitpos accordingly. */ + bitpos += ptr_bitpos; + if (TREE_CODE (exp) == MEM_REF + || TREE_CODE (exp) == TARGET_MEM_REF) + bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT; + } } else if (TREE_CODE (exp) == STRING_CST) {