aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2010-08-27 12:08:47 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2010-08-27 12:08:47 +0000
commite240f0f4cca760c8602ecc3f65c074bceb858f43 (patch)
treefa5f87e42396f0c207f585f44deca18f326f388b /gcc
parent6d446ecf6053a32a25ceab6bc0e19569ead2124e (diff)
downloadgcc-e240f0f4cca760c8602ecc3f65c074bceb858f43.zip
gcc-e240f0f4cca760c8602ecc3f65c074bceb858f43.tar.gz
gcc-e240f0f4cca760c8602ecc3f65c074bceb858f43.tar.bz2
re PR fortran/45159 (Unnecessary temporaries)
2010-08-27 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/45159 * dependency.c (check_section_vs_section): Single test for identical strides which takes into account that only one of the strides may be NULL. 2010-08-27 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/45159 * gfortran.dg/dependency_33.f90: New test. From-SVN: r163584
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/dependency.c36
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/dependency_33.f9011
4 files changed, 44 insertions, 15 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index f28030f..9bd81c3 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2010-08-27 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/45159
+ * dependency.c (check_section_vs_section): Single test for
+ identical strides which takes into account that only one
+ of the strides may be NULL.
+
2010-08-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/43217
diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c
index dfb0c94..ab75bde 100644
--- a/gcc/fortran/dependency.c
+++ b/gcc/fortran/dependency.c
@@ -1023,6 +1023,7 @@ check_section_vs_section (gfc_array_ref *l_ar, gfc_array_ref *r_ar, int n)
gfc_expr *r_lower;
gfc_expr *r_upper;
int r_dir;
+ bool identical_strides;
/* If they are the same range, return without more ado. */
if (gfc_is_same_range (l_ar, r_ar, n, 0))
@@ -1076,6 +1077,23 @@ check_section_vs_section (gfc_array_ref *l_ar, gfc_array_ref *r_ar, int n)
if (l_dir == 0 || r_dir == 0)
return GFC_DEP_OVERLAP;
+ /* Determine if the strides are equal. */
+
+ if (l_stride)
+ {
+ if (r_stride)
+ identical_strides = gfc_dep_compare_expr (l_stride, r_stride) == 0;
+ else
+ identical_strides = gfc_expr_is_one (l_stride, 0) == 1;
+ }
+ else
+ {
+ if (r_stride)
+ identical_strides = gfc_expr_is_one (r_stride, 0) == 1;
+ else
+ identical_strides = true;
+ }
+
/* Determine LHS upper and lower bounds. */
if (l_dir == 1)
{
@@ -1175,11 +1193,7 @@ check_section_vs_section (gfc_array_ref *l_ar, gfc_array_ref *r_ar, int n)
&& l_start && r_start && gfc_dep_compare_expr (l_start, r_start) == -1
&& l_end && r_end && gfc_dep_compare_expr (l_end, r_end) == -1)
{
- /* Check that the strides are the same. */
- if (!l_stride && !r_stride)
- return GFC_DEP_FORWARD;
- if (l_stride && r_stride
- && gfc_dep_compare_expr (l_stride, r_stride) == 0)
+ if (identical_strides)
return GFC_DEP_FORWARD;
}
@@ -1188,20 +1202,12 @@ check_section_vs_section (gfc_array_ref *l_ar, gfc_array_ref *r_ar, int n)
&& l_start && r_start && gfc_dep_compare_expr (l_start, r_start) == 1
&& l_end && r_end && gfc_dep_compare_expr (l_end, r_end) == 1)
{
- /* Check that the strides are the same. */
- if (!l_stride && !r_stride)
- return GFC_DEP_FORWARD;
- if (l_stride && r_stride
- && gfc_dep_compare_expr (l_stride, r_stride) == 0)
+ if (identical_strides)
return GFC_DEP_FORWARD;
}
- /* Are the strides the same? */
- if ((!l_stride && !r_stride)
- ||
- (l_stride && r_stride
- && gfc_dep_compare_expr (l_stride, r_stride) == 0))
+ if (identical_strides)
{
if (l_start && IS_ARRAY_EXPLICIT (l_ar->as))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d8b9801..1c1dc43 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-08-27 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/45159
+ * gfortran.dg/dependency_33.f90: New test.
+
2010-08-27 Richard Guenther <rguenther@suse.de>
* gcc.dg/graphite/scop-1.c: Fix out-of-bound array accesses.
diff --git a/gcc/testsuite/gfortran.dg/dependency_33.f90 b/gcc/testsuite/gfortran.dg/dependency_33.f90
new file mode 100644
index 0000000..cf6f175
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dependency_33.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-Warray-temporaries" }
+! No temporary should be created for this, as a missing stride and
+! a stride equal to one should be equal.
+program main
+ integer a(100)
+ a(10:16) = a(11:17)
+ a(10:16) = a(11:17:1)
+ a(10:16:1) = a(11:17)
+ a(10:16:1) = a(11:17:1)
+end program main