This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH] Make the _gfortran_pow* const
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Sat, 25 Nov 2006 20:47:45 -0800
- Subject: [PATCH] Make the _gfortran_pow* const
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:subject:to:content-type:date:message-id:mime-version:x-mailer:from; b=j/HtvK2s1o+3BaV4uc5WVMUxOfW+NZEQeFgrpCpcat8U9rjE2kpweEPASEblLIcUsvEyv6FupbB3dgn7VDuXkCH+vJwV7v3oVN9vx4d/1sACpScnIK5Hte+G38tk5KoDuiRLr+MBgWC8AD9PCFqJPyIQCn91U8y/DCbb2YZTwRM=
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;
}
}
}