[Patch, fortran] PR32239 Use builtin_powi
Richard Guenther
richard.guenther@gmail.com
Mon Jun 18 09:05:00 GMT 2007
On 6/17/07, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
> :ADDPATCH fortran:
>
> Hi,
>
> the attached patch changes gfortran to use builtin_powi for real**int4
> powers. This enables potentially better optimization, as the middle-end
> is not aware of the inner workings of __gfortran_pow_rn_i4. However, at
> the moment the vectorizer only vectorizes builtin_pow if the exponent is
> either 2 or 0.5, whereas if we expand constant exponents in the gfortran
> frontend (gfc_conv_cst_int_power) it vectorizes for other constant
> integer powers as well (the expansion by the frontend generates a number
> of calls to builtin_pow with exponent 2.0). So I left that part alone
> for now, i.e. builtin_powi is used only for real**int4 when int4 is
> non-constant. Also, it unfortunately seems the middle-end is not able to
> do the sort of optimization suggested in the PR, but perhaps some day.
>
> So I guess at the moment this is mostly a library bloat reduction patch,
> with some potential for better optimization in the future.
The optimization hinted at in the PR is strength-reducing the power [note
that this may have severe correctness issues!]. The RTL strength reducing
pass (yep - we don't do this on the tree level, but we could enhance PRE do
do this) doesn't know about function calls that may be strength-reduced.
Richard.
More information about the Fortran
mailing list