Commit 0e6640d8 by Paul Thomas

re PR fortran/40472 (Simplification of spread intrinsic takes a long time)

2009-06-22  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/40472
	* simplify.c (gfc_simplify_spread): Restrict the result size to
	the limit for an array constructor.

2009-06-22  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/40472
	* gfortran.dg/spread_size_limit.f90: New test.

From-SVN: r148775
parent e9402aab
2009-06-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40472
* simplify.c (gfc_simplify_spread): Restrict the result size to
the limit for an array constructor.
2009-06-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/39850
......
......@@ -5099,6 +5099,7 @@ gfc_simplify_spread (gfc_expr *source, gfc_expr *dim_expr, gfc_expr *ncopies_exp
{
gfc_expr *result = 0L;
int i, j, dim, ncopies;
mpz_t size;
if ((!gfc_is_constant_expr (source)
&& !is_constant_array_expr (source))
......@@ -5114,6 +5115,12 @@ gfc_simplify_spread (gfc_expr *source, gfc_expr *dim_expr, gfc_expr *ncopies_exp
gfc_extract_int (ncopies_expr, &ncopies);
ncopies = MAX (ncopies, 0);
/* Do not allow the array size to exceed the limit for an array
constructor. */
gfc_array_size (source, &size);
if (mpz_get_si (size)*ncopies > gfc_option.flag_max_array_constructor)
return NULL;
if (source->expr_type == EXPR_CONSTANT)
{
gcc_assert (dim == 0);
......
2009-06-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40472
* gfortran.dg/spread_size_limit.f90: New test.
2009-06-21 Uros Bizjak <ubizjak@gmail.com>
* gcc.c-torture/unsorted/dump-noaddr.x (dump_compare): Use --dumpbase
......
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
!
! Test the fix for PR40472 in which simplify_spread had mo limit on the
! siz that it would try to expand to.
!
! Contributed by Philippe Marguinaud <philippe.marguinaud@meteo.fr>
!
REAL, DIMENSION(720,360) :: ZLON_MASK
ZLON_MASK(:,:)= SPREAD( (/ (JLON , JLON=1,720) /) , DIM=2, NCOPIES=360 )
print *, zlon_mask(100,100)
END
! { dg-final { scan-tree-dump-times "_gfortran_spread" 1 "original" } }
! { dg-final { cleanup-tree-dump "original" } }
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