Yet Another Opportunity to Optimize by the Front End.
Paul Thomas
paulthomas2@wanadoo.fr
Mon Oct 30 23:05:00 GMT 2006
Toon,
>
> allocate (temp (m,n))
> loop over n
> loop over m
> temp (...) = x(...) == y(...)
> loop over n
> loop over m
> all = all .and. temp(...)
>
Steven and Paul were more intelligent than that:
integer, parameter :: N = 10
type :: toon
integer :: wim (N) = (/(i, i = 1, N)/)
end type toon
type (toon) :: current
integer :: wim(N) = (/(i, i = 1, N)/)
call moene (wim)
contains
subroutine moene (wim)
integer :: wim (N)
if (any(current%wim /= wim)) call abort ()
end subroutine moene
end
produces:
moene (wim)
{
int4[10] * D.951;
logical4 test.0;
test.0 = 0;
D.951 = ¤t.wim;
{
int4 S.1;
S.1 = 1;
while (1)
{
if (S.1 > 10) goto L.2; else (void) 0;
if ((*D.951)[NON_LVALUE_EXPR <S.1> + -1] !=
(*wim)[NON_LVALUE_EXPR <S.1> + -1] != 0)
{
test.0 = 1;
goto L.1;
}
else
{
(void) 0;
}
S.1 = S.1 + 1;
}
L.2:;
}
L.1:;
if (test.0)
{
_gfortran_abort ();
}
else
{
(void) 0;
}
}
MAIN__ ()
{
static struct toon current = {.wim={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
int4 i;
static int4 wim[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
static void moene (int4[10] *);
_gfortran_set_std (70, 127, 0);
moene (&wim);
}
ie. there is a single loop with an early bale-out for the condition
being met.
Or have I misunderstood what you are wanting to do?
Cheers
Paul
More information about the Fortran
mailing list