aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/dependency.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2010-08-06 22:33:37 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2010-08-06 22:33:37 +0000
commit8a0f25c3e783c450c75a139adf91c826584afd10 (patch)
treeafb755fd34f651600e8426249fc34454e366a43a /gcc/fortran/dependency.c
parentcd6b2fa0e7cc07a7007f4928813f14cc940c50d9 (diff)
downloadgcc-8a0f25c3e783c450c75a139adf91c826584afd10.zip
gcc-8a0f25c3e783c450c75a139adf91c826584afd10.tar.gz
gcc-8a0f25c3e783c450c75a139adf91c826584afd10.tar.bz2
re PR fortran/45159 (Unnecessary temporaries)
2010-08-06 Thomas Koenig <tkoenig@gcc.gnu.org> 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 <tkoenig@gcc.gnu.org> PR fortran/45159 * gfortran.dg/dependency_31.f90: New test. From-SVN: r162966
Diffstat (limited to 'gcc/fortran/dependency.c')
-rw-r--r--gcc/fortran/dependency.c24
1 files changed, 22 insertions, 2 deletions
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