From 8a0f25c3e783c450c75a139adf91c826584afd10 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Fri, 6 Aug 2010 22:33:37 +0000 Subject: re PR fortran/45159 (Unnecessary temporaries) 2010-08-06 Thomas Koenig PR fortran/45159 * dependency.c (check_section_vs_section): Handle cases where the start expression coincides with the lower or upper bound of the array. 2010-08-06 Thomas Koenig PR fortran/45159 * gfortran.dg/dependency_31.f90: New test. From-SVN: r162966 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/dependency.c | 24 ++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 752b187..fa2aaa6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2010-08-06 Thomas Koenig + + PR fortran/45159 + * dependency.c (check_section_vs_section): Handle cases where + the start expression coincides with the lower or upper + bound of the array. + 2010-08-04 Janus Weil PR fortran/42207 diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index 90b2d67..dfb0c94 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -1196,13 +1196,33 @@ check_section_vs_section (gfc_array_ref *l_ar, gfc_array_ref *r_ar, int n) return GFC_DEP_FORWARD; } - /* Check for backward dependencies: - Are the strides the same?. */ + + /* Are the strides the same? */ if ((!l_stride && !r_stride) || (l_stride && r_stride && gfc_dep_compare_expr (l_stride, r_stride) == 0)) { + + if (l_start && IS_ARRAY_EXPLICIT (l_ar->as)) + { + + /* Check for a(low:y:s) vs. a(z:a:s) where a has a lower bound + of low, which is always at least a forward dependence. */ + + if (r_dir == 1 + && gfc_dep_compare_expr (l_start, l_ar->as->lower[n]) == 0) + return GFC_DEP_FORWARD; + + /* Check for a(high:y:-s) vs. a(z:a:-s) where a has a higher bound + of high, which is always at least a forward dependence. */ + + if (r_dir == -1 + && gfc_dep_compare_expr (l_start, l_ar->as->upper[n]) == 0) + return GFC_DEP_FORWARD; + } + + /* From here, check for backwards dependencies. */ /* x:y vs. x+1:z. */ if (l_dir == 1 && r_dir == 1 && l_start && r_start -- cgit v1.1