From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15559 invoked by alias); 16 Jan 2012 15:43:30 -0000 Received: (qmail 15546 invoked by uid 22791); 16 Jan 2012 15:43:28 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Mon, 16 Jan 2012 15:43:15 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/50444] [4.6/4.7 Regression] -ftree-sra ignores alignment Date: Mon, 16 Jan 2012 15:58: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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.3 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-01/txt/msg01795.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50444 --- Comment #13 from Richard Guenther 2012-01-16 15:41:50 UTC --- Or, transfering the alignment: Index: tree-sra.c =================================================================== --- tree-sra.c (revision 183205) +++ tree-sra.c (working copy) @@ -2294,15 +2294,17 @@ propagate_subaccesses_across_link (struc { tree t = lacc->base; - lacc->type = racc->type; - if (build_user_friendly_ref_for_offset (&t, TREE_TYPE (t), - lacc->offset, racc->type)) + if (lacc->type == racc->type + && build_user_friendly_ref_for_offset (&t, TREE_TYPE (t), + lacc->offset, lacc->type)) lacc->expr = t; else { - lacc->expr = build_ref_for_model (EXPR_LOCATION (lacc->base), - lacc->base, lacc->offset, - racc, NULL, false); + lacc->type = build_aligned_type (racc->type, + get_object_alignment (lacc->expr)); + lacc->expr = build_ref_for_offset (EXPR_LOCATION (lacc->base), + lacc->base, lacc->offset, + lacc->type, NULL, false); lacc->grp_no_warning = true; } } note the build_user_friendly_ref_for_offset which is really bogus as it would construct component-refs out of thin air. The above probably completely disables that path ... get_object_alignment is a little conservative - we can and need to do better by mimicking what expand does. Note that we can't use build_ref_for_model here. With the above the testcase passes as well and we still scalarize: SR.7_10 = SR.6_11; c1x128$m_2 = SR.7_10; c4x32_15 = c1x128$m_2; MEM[(struct *)&D.1760] = c4x32_15;