Hello world, the attached patch is a front-end optimization which replaces multiple calls to a function with identical argument lists with an assignment to a temporary variable, and then uses that variable in the original expression. AFAIK, this is permitted by the Fortran standard because such functions have side effects, the program is illegal. OK for trunk, now that it has reopened? Thomas 2010-03-14 Thomas Koenig PR fortran/22572 * frontend_passes (expr_array): New static variable. (expr_size): Likewise. (expr_count): Likewise. (current_code): Likewise. (current_ns): Likewise. (gfc_run_passes): Allocate and free space for expressions. (compare_functions): New function. (cfe_expr): New function. (create_var): New function. (cfc_expr_0): New function. (cfe_code): New function. (optimize_namespace): Invoke gfc_code_walker with cfe_code and cfe_expr_0. 2010-03-14 Thomas Koenig PR fortran/22572 * gfortran.dg/function_optimize_1.f90: New test.