simplification of SIN
Daniel Franke
franke.daniel@gmail.com
Wed Dec 10 15:18:00 GMT 2008
Hi all.
Could somebody knowledgeable of simplifying be so kind to comment on why SIN
is not simplified if called with a constant array argument?
Or phrased differently, why simplification is attempted on the whole array (x-
>expr_type == EXPR_ARRAY in gfc_simplify_sin), instead of the single,
constant, elements?
Is this necessary for some reason or "just" a missed optimization?
Thanks
Daniel
==============================================
$> cat scalar.f90
REAL :: a
a = sin(0.0)
end
$> gfortran-svn -fdump-tree-original scalar.f90
$> cat scalar.f90.003t.original
MAIN__ ()
{
real(kind=4) a;
static integer(kind=4) options.0[8] = {68, 255, 0, 0, 0, 1, 0, 1};
_gfortran_set_options (8, (void *) &options.0);
a = 0.0;
}
==============================================
$> cat array.f90
REAL :: a(1)
a = sin([0.0])
end
$> gfortran-svn -fdump-tree-original array.f90
$> cat array.f90.003t.original
MAIN__ ()
{
real(kind=4) a[1];
static integer(kind=4) options.0[8] = {68, 255, 0, 0, 0, 1, 0, 1};
_gfortran_set_options (8, (void *) &options.0);
{
static real(kind=4) A.1[1] = {0.0};
{
integer(kind=4) S.2;
S.2 = 0;
while (1)
{
if (S.2 > 0) goto L.1;
a[S.2] = __builtin_sinf (A.1[S.2]);
S.2 = S.2 + 1;
}
L.1:;
}
}
}
==============================================
If used as initialization expression, gfc_simplify_sin() is called 2 + SIZE(a)
times, then being simplified as expected:
$> cat array_2.f90
REAL :: a(1) = sin([0.0])
REAL b
b = a(1)
end
$> gfortran-svn -fdump-tree-original array_2.f90
$> cat array_2.f90.003t.original
MAIN__ ()
{
static real(kind=4) a[1] = {0.0};
real(kind=4) b;
static integer(kind=4) options.0[8] = {68, 255, 0, 0, 0, 1, 0, 1};
_gfortran_set_options (8, (void *) &options.0);
b = a[0];
}
More information about the Fortran
mailing list