This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Make the _gfortran_pow* const


Hi,
  This patch makes the _gfortran_pow* function constant functions as the
return value is only dependent on those values and they don't have any
special side effects.

This patch speeds up my father's code by about 10% where he has a couple
of rd**3.

OK? Bootstrapped and tested on i686-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

	* trans-decl.c (gfc_build_intrinsic_function_decls): Mark the
	pow functions as constant functions.
Index: fortran/trans-decl.c
===================================================================
--- fortran/trans-decl.c	(revision 119211)
+++ fortran/trans-decl.c	(working copy)
@@ -2112,6 +2112,7 @@ gfc_build_intrinsic_function_decls (void
 		gfor_fndecl_math_powi[jkind][ikind].integer =
 		  gfc_build_library_function_decl (get_identifier (name),
 		    jtype, 2, jtype, itype);
+		TREE_READONLY (gfor_fndecl_math_powi[jkind][ikind].integer) = 1;
 	      }
 	  }
 
@@ -2125,6 +2126,7 @@ gfc_build_intrinsic_function_decls (void
 		gfor_fndecl_math_powi[rkind][ikind].real =
 		  gfc_build_library_function_decl (get_identifier (name),
 		    rtype, 2, rtype, itype);
+		TREE_READONLY (gfor_fndecl_math_powi[rkind][ikind].real) = 1;
 	      }
 
 	    ctype = gfc_get_complex_type (rkinds[rkind]);
@@ -2135,6 +2137,7 @@ gfc_build_intrinsic_function_decls (void
 		gfor_fndecl_math_powi[rkind][ikind].cmplx =
 		  gfc_build_library_function_decl (get_identifier (name),
 		    ctype, 2,ctype, itype);
+		TREE_READONLY (gfor_fndecl_math_powi[rkind][ikind].cmplx) = 1;
 	      }
 	  }
       }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]