[Fwd: question on optimizing calls to library functions]
Richard Guenther
richard.guenther@gmail.com
Wed Dec 10 20:14:00 GMT 2008
On Wed, Dec 10, 2008 at 5:55 PM, Daniel Franke <franke.daniel@gmail.com> wrote:
> On Wednesday 10 December 2008 17:31:17 Richard Guenther wrote:
>> So what you want is to tell the middle-end that the function result is
>> only dependent on the memory reachable from its argument (remember, you
>> pass in fortran array descriptors, right?) and its only side-effect is
>> storing to reachable memory of a specific argument.
>>
>> If that is know the compiler can CSE the call given that it can prove the
>> arguments are the same. If it would be implemented, of course.
>
> This is what I assumed could be done, yes. If it's feasible, that's a
> different question, but ...
>
>
>> I don't know if CSEing matmul is useful though. For scalar functions (ok,
>> again you have the pass-by-reference problem here) you should tell the
>> compiler by making the functions const or pure.
>
> ... it could be worth a try. Especially as there a plenty of functions in
> libgfortran that could benefit :)
>
> Which brings us back to the initial question: how does one mark them as pure
> or const? Are ATTR_PURE and friends the right way to go? Where, and how can or
> should these attributes be applied?
The FE should mark the decls for the libgfortran entries with TREE_READONLY
(for const functions) or DECL_PURE_P (for pure functions). There is also
DECL_IS_NOVOPS for "does not read/write caller visible memory but has
other side-effects"
(for example a prng would be in this class). And there is
DECL_LOOPING_CONST_OR_PURE_P for pure or const functions that may
not terminate (a side-effect we want to preserve).
> These questions are probably quite basic, but this is uncharted land for me.
> There be dragons, I expect.
;)
Richard.
More information about the Fortran
mailing list