Commit 8a0f25c3 by Thomas Koenig

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
parent cd6b2fa0
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-04 Janus Weil <janus@gcc.gnu.org> 2010-08-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/42207 PR fortran/42207
......
...@@ -1196,13 +1196,33 @@ check_section_vs_section (gfc_array_ref *l_ar, gfc_array_ref *r_ar, int n) ...@@ -1196,13 +1196,33 @@ check_section_vs_section (gfc_array_ref *l_ar, gfc_array_ref *r_ar, int n)
return GFC_DEP_FORWARD; return GFC_DEP_FORWARD;
} }
/* Check for backward dependencies:
Are the strides the same?. */ /* Are the strides the same? */
if ((!l_stride && !r_stride) if ((!l_stride && !r_stride)
|| ||
(l_stride && r_stride (l_stride && r_stride
&& gfc_dep_compare_expr (l_stride, r_stride) == 0)) && 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. */ /* x:y vs. x+1:z. */
if (l_dir == 1 && r_dir == 1 if (l_dir == 1 && r_dir == 1
&& l_start && r_start && l_start && r_start
......
2010-08-06 Thomas Koenig <tkoenig@gcc.gnu.org> 2010-08-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/45159
* gfortran.dg/dependency_31.f90: New test.
2010-08-06 Thomas Koenig <tkoenig@gcc.gnu.org>
* gfortran.dg/dependency_30.f90: Fix incorrect dg-do line. * gfortran.dg/dependency_30.f90: Fix incorrect dg-do line.
2010-08-06 Jason Merrill <jason@redhat.com> 2010-08-06 Jason Merrill <jason@redhat.com>
......
! { dg-do compile }
! { dg-options "-Warray-temporaries" }
! PR 45159 - make sure no temporary is created for this.
subroutine foo(a,n,i,j)
implicit none
integer, intent(in) :: i,j,n
real, dimension(20) :: a
a(1:10) = a(i:j)
a(20:n:-3) = a(n:i:-3)
end subroutine foo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment