There appears to be a missed opportunity to optimize
away exponential operators. I suspect that this
falls under gfortrani's frontend-optimize option, but
it may also be a middle-end issue.
Consider,
subroutine foo(n)
integer n
integer i, j
i = 2
j = 4
n = i**j ! <-- This should evaluate to 16 without a function call.
end subroutine foo
% gfortran -O -fdump-tree-original -fdump-tree-optimized foo.f90
% cat a.f90.003t.original
foo (integer(kind=4) & restrict n)
{
integer(kind=4) i;
integer(kind=4) j;
i = 2;
j = 4;
{
integer(kind=4) D.3382;
D.3382 = i;
*n = _gfortran_pow_i4_i4 (D.3382, j);
}
}
% cat a.f90.188t.optimized
;; Function foo (foo_, funcdef_no=0, decl_uid=3377, cgraph_uid=0,
symbol_order=0)
foo (integer(kind=4) & restrict n)
{
integer(kind=4) _1;
<bb 2>:
_1 = _gfortran_pow_i4_i4 (2, 4);
*n_3(D) = _1;
return;
}
I don't know if it is possible to get the optimizer to recognize
the _gfortran_pow_i4_i4 (2, 4) can be replaced by 16.
--
steve