------- Comment #1 from pault at gcc dot gnu dot org 2008-11-06 21:09 -------
(In reply to comment #0)
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (revision 141655)
+++ gcc/fortran/trans-array.c (working copy)
@@ -645,13 +645,16 @@
{
n = loop->order[dim];
if (n < loop->temp_dim)
- gcc_assert (integer_zerop (loop->from[n]));
+ gcc_assert (integer_zerop (loop->from[n]));
else
{
/* Callee allocated arrays may not have a known bound yet. */
if (loop->to[n])
- loop->to[n] = fold_build2 (MINUS_EXPR, gfc_array_index_type,
- loop->to[n], loop->from[n]);
+ {
+ tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ loop->to[n], loop->from[n]);
+ loop->to[n] = gfc_evaluate_now (tmp, pre);
+ }
loop->from[n] = gfc_index_zero_node;
}
Removes the _gfortran_size0 calls from the loop but I have not yet located the
doubling up of calls here:
D.1551 = temp.offset;
D.1552 = &a;
D.1553 = (integer(kind=8)) (integer(kind=4)) _gfortran_size0 (D.1552);
D.1554 = &a;
D.1555 = (integer(kind=8)) (integer(kind=4)) _gfortran_size0 (D.1554) + -1;
atmp.1.dtype = 281;
atmp.1.dim[0].stride = 1;
atmp.1.dim[0].lbound = 0;
atmp.1.dim[0].ubound = D.1555;
D.1557 = D.1555 + 1 <= 0;
D.1558 = D.1555 + 1;
D.1559 = D.1557 ? 0 : D.1558 * 4;
if (D.1559 < 0)
{
_gfortran_runtime_error (&"Attempt to allocate a negative amount of
memory."[1]{lb: 1 sz: 1});
}
D.1560 = __builtin_malloc (MAX_EXPR <D.1559, 1>);
if (D.1560 == 0B)
{
_gfortran_os_error (&"Memory allocation failed"[1]{lb: 1 sz: 1});
}
D.1561 = D.1560;
atmp.1.data = D.1561;
atmp.1.offset = 0;
D.1563 = NON_LVALUE_EXPR <D.1548>;
{
integer(kind=8) D.1566;
integer(kind=8) D.1565;
integer(kind=8) S.2;
D.1565 = a.dim[0].stride;
D.1566 = temp.dim[0].stride;
S.2 = 0;
while (1)
{
if (S.2 > D.1555) goto L.1;
(*(real(kind=4)[0:] *) atmp.1.data)[S.2] = (*D.1546)[(S.2 + D.1563) *
D.1565 + D.1547];
S.2 = S.2 + 1;
}
L.1:;
S.2 = 0;
while (1)
{
if (S.2 > D.1555) goto L.2;
(*D.1550)[(S.2 + 1) * D.1566 + D.1551] = (*(real(kind=4)[0:] *)
atmp.1.data)[S.2];
S.2 = S.2 + 1;
}
L.2:;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033