Skip to main content
deleted 8 characters in body
Source Link
supercat
  • 2.3k
  • 3
  • 11

In many cases, an assignment expression which contains two or moreany function calls will need to save one or more temporary values around all but one of the function calls. If one can perform the Putting a function call before evaluating any other part of the expression, then "all but one" would translate evaluation will avoid the need to "none"store any values related to the evaluation across the call.

For example, given extern int *a,*b,*f(void);, all of the assignments *a=*f()+*b;, *a=*b+f();, and *f() = *a+*b; would be processed most efficiently by performing the function call before the loads of a and b, despite the fact that the function calls appear at different places within the expression.

Performing function calls early is often not considered an "optimization" as such, but may be performed as part of basic code generation if a tree-based expression handler distinguishes between "simple" and "complicated" operands, and processes complicated operands before simple ones.

In many cases, an assignment expression which contains two or more function calls will need to save one or more temporary values around all but one of the function calls. If one can perform the function call before evaluating any other part of the expression, then "all but one" would translate to "none".

For example, given extern int *a,*b,*f(void);, all of the assignments *a=*f()+*b;, *a=*b+f();, and *f() = *a+*b; would be processed most efficiently by performing the function call before the loads of a and b, despite the fact that the function calls appear at different places within the expression.

In many cases, an assignment expression which contains any function calls will need to save one or more temporary values around all but one of the function calls. Putting a function call before any other part of the expression evaluation will avoid the need to store any values related to the evaluation across the call.

For example, given extern int *a,*b,*f(void);, all of the assignments *a=*f()+*b;, *a=*b+f();, and *f() = *a+*b; would be processed most efficiently by performing the function call before the loads of a and b, despite the fact that the function calls appear at different places within the expression.

Performing function calls early is often not considered an "optimization" as such, but may be performed as part of basic code generation if a tree-based expression handler distinguishes between "simple" and "complicated" operands, and processes complicated operands before simple ones.

Source Link
supercat
  • 2.3k
  • 3
  • 11

In many cases, an assignment expression which contains two or more function calls will need to save one or more temporary values around all but one of the function calls. If one can perform the function call before evaluating any other part of the expression, then "all but one" would translate to "none".

For example, given extern int *a,*b,*f(void);, all of the assignments *a=*f()+*b;, *a=*b+f();, and *f() = *a+*b; would be processed most efficiently by performing the function call before the loads of a and b, despite the fact that the function calls appear at different places within the expression.