From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91613 invoked by alias); 11 Mar 2015 09:54:21 -0000 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 Received: (qmail 91564 invoked by uid 48); 11 Mar 2015 09:54:17 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/65310] vectorizer uses wrong alignment Date: Wed, 11 Mar 2015 09:54: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-Version: 5.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01206.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65310 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jamborm at gcc dot gnu.org --- Comment #9 from Richard Biener --- It's early SRA dropping alignment info. - # .MEM_48 = VDEF <.MEM_47> - # lhs access alignment 128+0 - D.2264.theX = _31; - # .MEM_49 = VDEF <.MEM_48> - # lhs access alignment 128+32 - D.2264.theY = _34; - # .MEM_50 = VDEF <.MEM_49> - # lhs access alignment 128+64 - D.2264.theZ = _37; - # .MEM_51 = VDEF <.MEM_50> - # lhs access alignment 128+96 - D.2264.theT = _40; - # .MEM_52 = VDEF <.MEM_51> - # lhs access alignment 128+0 - # rhs access alignment 128+0 - *res_7(D) = D.2264; - # .MEM_9 = VDEF <.MEM_52> + SR.22_44 = _31; + SR.23_43 = _34; + SR.24_42 = _37; + SR.25_41 = _40; + # .MEM_8 = VDEF <.MEM_1(D)> + # lhs access alignment 32+0 + MEM[(struct LorentzVector *)res_7(D)] = SR.22_44; + # .MEM_53 = VDEF <.MEM_8> + # lhs access alignment 32+0 + MEM[(struct LorentzVector *)res_7(D) + 4B] = SR.23_43; + # .MEM_54 = VDEF <.MEM_53> + # lhs access alignment 32+0 + MEM[(struct LorentzVector *)res_7(D) + 8B] = SR.24_42; + # .MEM_55 = VDEF <.MEM_54> + # lhs access alignment 32+0 + MEM[(struct LorentzVector *)res_7(D) + 12B] = SR.25_41; + # .MEM_9 = VDEF <.MEM_55> of course as it splits up the aggregate store and we can't represent align + known misalignment with the type used on the MEM_REF we are somewhat lost here. We can do better for the first and the third store though: # .MEM_8 = VDEF <.MEM_1(D)> # lhs access alignment 128+0 MEM[(struct LorentzVector *)res_7(D)] = SR.22_44; # .MEM_53 = VDEF <.MEM_8> # lhs access alignment 32+0 MEM[(struct LorentzVector *)res_7(D) + 4B] = SR.23_43; # .MEM_54 = VDEF <.MEM_53> # lhs access alignment 64+0 MEM[(struct LorentzVector *)res_7(D) + 8B] = SR.24_42; # .MEM_55 = VDEF <.MEM_54> # lhs access alignment 32+0 MEM[(struct LorentzVector *)res_7(D) + 12B] = SR.25_41; that seems to be enough here as the vectorizer is clever enough to only care about the first ref alignment of a group access. Phew ;) Testing Index: gcc/tree-sra.c =================================================================== --- gcc/tree-sra.c (revision 221324) +++ gcc/tree-sra.c (working copy) @@ -1597,7 +1597,7 @@ build_ref_for_offset (location_t loc, tr misalign = (misalign + offset) & (align - 1); if (misalign != 0) align = (misalign & -misalign); - if (align < TYPE_ALIGN (exp_type)) + if (align != TYPE_ALIGN (exp_type)) exp_type = build_aligned_type (exp_type, align); mem_ref = fold_build2_loc (loc, MEM_REF, exp_type, base, off);