Message ID | 51EA9B78.6030200@netcologne.de |
---|---|
State | New |
Headers | show |
Hi Thomas, This is OK for trunk. Could you expand the comment to capture the two cases without dependency. eg. There is no dependency if the vector indices are equal or things are known to be different in a different dimension. Thanks for the patch! Paul On 20 July 2013 16:15, Thomas Koenig <tkoenig@netcologne.de> wrote: > Hello world, > > the attached patch fixes two cases of unnecessary array temporaries > when vector indices were involved. When we saw something like that, > we gave up even if > > - The vector indices were equal > - The vector indices didn't matter at all because, in a different > dimension, things were known to be different. > > Regression-tested. OK for trunk? > > Thomas > > 2013-07-20 Thomas Koenig <tkoenig@gcc.gnu.org> > > PR fortran/56937 > * dependency.c (gfc_dep_resolver): Treat identical > array subscripts as identical; don't unconditionally > return a dependency if an array subscript is found. > > 2013-07-20 Thomas Koenig <tkoenig@gcc.gnu.org> > > PR fortran/56937 > * gfortran.dg/dependency_42.f90: New test. > * gfortran.dg/dependency_43.f90: New test.
Hi Paul, > This is OK for trunk. Could you expand the comment to capture the two > cases without dependency. eg. > There is no dependency if the vector indices are equal or things are > known to be different in a different dimension. Committed to trunk with an updated comment, as you suggested, as rev. 201094. Thanks for the review! Regards Thomas
Index: dependency.c =================================================================== --- dependency.c (Revision 200743) +++ dependency.c (Arbeitskopie) @@ -2095,12 +2095,22 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gf for (n=0; n < lref->u.ar.dimen; n++) { - /* Assume dependency when either of array reference is vector - subscript. */ + /* Handle dependency when either of array reference is vector + subscript. Assume dependency unless they are identical. */ if (lref->u.ar.dimen_type[n] == DIMEN_VECTOR || rref->u.ar.dimen_type[n] == DIMEN_VECTOR) - return 1; + { + if (lref->u.ar.dimen_type[n] == DIMEN_VECTOR + && rref->u.ar.dimen_type[n] == DIMEN_VECTOR + && gfc_dep_compare_expr (lref->u.ar.start[n], + rref->u.ar.start[n]) == 0) + this_dep = GFC_DEP_EQUAL; + else + this_dep = GFC_DEP_OVERLAP; + goto update_fin_dep; + } + if (lref->u.ar.dimen_type[n] == DIMEN_RANGE && rref->u.ar.dimen_type[n] == DIMEN_RANGE) this_dep = check_section_vs_section (&lref->u.ar, &rref->u.ar, n); @@ -2164,6 +2174,8 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gf /* Overlap codes are in order of priority. We only need to know the worst one.*/ + + update_fin_dep: if (this_dep > fin_dep) fin_dep = this_dep; }