From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10851 invoked by alias); 12 May 2011 13:54:46 -0000 Received: (qmail 10840 invoked by uid 22791); 12 May 2011 13:54:45 -0000 X-SWARE-Spam-Status: No, hits=-2.7 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; Thu, 12 May 2011 13:53:58 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/48172] [4.5/4.6/4.7 Regression] incorrect vectorization of loop in GCC 4.5.* with -O3 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: critical X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.5.4 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 Date: Thu, 12 May 2011 13:55:00 -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 X-SW-Source: 2011-05/txt/msg01023.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48172 --- Comment #12 from Richard Guenther 2011-05-12 12:46:10 UTC --- Like this? Index: gcc/tree-vect-loop-manip.c =================================================================== --- gcc/tree-vect-loop-manip.c (revision 173703) +++ gcc/tree-vect-loop-manip.c (working copy) @@ -2353,23 +2353,19 @@ vect_create_cond_for_align_checks (loop_ Input: DR: The data reference. - VECT_FACTOR: vectorization factor. - SCALAR_LOOP_NITERS: number of iterations. + LENGTH_FACTOR: segment length to consider. Return an expression whose value is the size of segment which will be accessed by DR. */ static tree -vect_vfa_segment_size (struct data_reference *dr, int vect_factor, +vect_vfa_segment_size (struct data_reference *dr, tree length_factor, tree scalar_loop_niters) { tree segment_length; segment_length = size_binop (MULT_EXPR, fold_convert (sizetype, DR_STEP (dr)), - size_int (vect_factor)); - segment_length = size_binop (MULT_EXPR, - segment_length, - fold_convert (sizetype, scalar_loop_niters)); + fold_convert (sizetype, length_factor)); if (vect_supportable_dr_alignment (dr, false) == dr_explicit_realign_optimized) { @@ -2465,10 +2461,12 @@ vect_create_cond_for_alias_checks (loop_ vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list, NULL_TREE, loop); - segment_length_a = vect_vfa_segment_size (dr_a, vect_factor, - scalar_loop_iters); - segment_length_b = vect_vfa_segment_size (dr_b, vect_factor, - scalar_loop_iters); + if (!operand_equal_p (DR_STEP (dr_a), DR_STEP (dr_b), 0)) + length_factor = scalar_loop_iters; + else + length_factor = size_int (vect_factor); + segment_length_a = vect_vfa_segment_size (dr_a, length_factor); + segment_length_b = vect_vfa_segment_size (dr_b, length_factor); if (vect_print_dump_info (REPORT_DR_DETAILS)) { I also think that the re-alignment adjustment needs to be multiplied by DR_STEP (maybe we only support it for DR_STEP == 1 at the moment).