From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27724 invoked by alias); 16 Dec 2011 00:33:31 -0000 Received: (qmail 27715 invoked by uid 22791); 16 Dec 2011 00:33:30 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_TM 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; Fri, 16 Dec 2011 00:33:17 +0000 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49444] IV-OPTs changes an unaligned loads into aligned loads incorrectly Date: Fri, 16 Dec 2011 00: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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: 2011-12/txt/msg01755.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49444 --- Comment #6 from Andrew Pinski 2011-12-16 00:33:10 UTC --- This is the patch which I ended up with: Index: tree-ssa-loop-ivopts.c =================================================================== --- tree-ssa-loop-ivopts.c (revision 61449) +++ tree-ssa-loop-ivopts.c (revision 61858) @@ -6066,6 +6066,7 @@ rewrite_use_address (struct ivopts_data tree base_hint = NULL_TREE; tree ref, iv; bool ok; + tree type; adjust_iv_update_pos (cand, use); ok = get_computation_aff (data->current_loop, use, cand, use->stmt, &aff); @@ -6087,7 +6088,13 @@ rewrite_use_address (struct ivopts_data base_hint = var_at_stmt (data->current_loop, cand, use->stmt); iv = var_at_stmt (data->current_loop, cand, use->stmt); - ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff, + type = TREE_TYPE (*use->op_p); + if (TREE_CODE (*use->op_p) == COMPONENT_REF) + { + unsigned align = DECL_ALIGN (TREE_OPERAND (*use->op_p, 1)); + type = build_aligned_type (type, align); + } + ref = create_mem_ref (&bsi, type, &aff, reference_alias_ptr_type (*use->op_p), iv, base_hint, data->speed); copy_ref_info (ref, *use->op_p); --- CUT --- I also implemented on mips the misalignedmove patterns too.