http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49771
Ira Rosen <irar at il dot ibm.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |irar at il dot ibm.com --- Comment #3 from Ira Rosen <irar at il dot ibm.com> 2011-07-18 15:55:49 UTC --- (In reply to comment #2) > That commit looks bogus, the change it made is: > # ivtmp.37_45 = PHI <ivtmp.37_43(6), ivtmp.37_46(2)> > vect_pa.7_44 = (vector(4) int *) ivtmp.37_45; > - D.2731_1 = vect_pa.7_44 < &a; > - D.2733_14 = vect_pa.7_44 > &a[1000]; > + D.2731_1 = vect_pa.7_44 <= &a; > + D.2733_14 = vect_pa.7_44 >= &a[1000]; > D.2734_23 = D.2733_14 | D.2731_1; > if (D.2734_23 != 0) > > vect_pa.7_44 is the pointer that goes from &a[0] to &a[999]. While in this > case it is fine to change the second > to >=, changing the first one is of > course wrong, because in the first iteration it will overlap, yet this test > will say that they do not. > What is weird is that segment_length_a in vect_create_cond_for_alias_checks > is 0 instead of 4 (sizeof (int)) I'd expect, while segment_length_b is the > expected 4000. Apparently DR_STEP in the first case is 0. The step of a[i] is indeed 0 in the j loop. > I wonder whether > the change of the comparison should only be done if one segment length is > empty > (and thus clearly doesn't include all bytes of the read/store), or something > similar. We can create a segment of length sizeof(type) for the zero step case: Index: tree-vect-loop-manip.c =================================================================== --- tree-vect-loop-manip.c (revision 176389) +++ tree-vect-loop-manip.c (working copy) @@ -2356,9 +2356,14 @@ static tree vect_vfa_segment_size (struct data_reference *dr, tree length_factor) { tree segment_length; - segment_length = size_binop (MULT_EXPR, - fold_convert (sizetype, DR_STEP (dr)), - fold_convert (sizetype, length_factor)); + + if (!compare_tree_int (DR_STEP (dr), 0)) + segment_length = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr))); + else + segment_length = size_binop (MULT_EXPR, + fold_convert (sizetype, DR_STEP (dr)), + fold_convert (sizetype, length_factor)); + if (vect_supportable_dr_alignment (dr, false) == dr_explicit_realign_optimized) { (tested only with the vectorizer testsuite). Ira