On Apr 24, 2007, at 8:30 AM, Wolfgang Gellerich wrote:
What is the policy concerning the usage of SAVE_EXPRs?

Roughly, if you do something like:

  tree foo(a, b)
    return build (a, b);

You don't need any saving.  If you do:

  tree foo(a, b)
    return build (a, build (a, b));

You need to code this as:

  tree foo(a, b)
    a = save_expr (a);
    return build (a, build (a, b));

The person that does the building, does the saving, as they know they are going to reuse a value and duplicate evaluations would be wrong.

I thought the respective language front end were responsible to enclose any expressions with side
effects this way

No. The first example above needs no saving. Only when a value is used more than once, does it need to be saved.

However, also some of the code translating tree nodes into rtxes like
some functions found in builtins.c worry about the re-evaluation of
arguments and insert plenty of SAVE_EXPRs. Why is that necessary?

Because they do as in the second example above.

Reply via email to