This is the mail archive of the
mailing list for the GCC project.
[patch, fortran] PR46331 Compilation time long with simple function in array constructor
- From: Jerry DeLisle <jvdelisle at frontier dot com>
- To: gfortran <fortran at gcc dot gnu dot org>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 07 Nov 2010 18:40:32 -0800
- Subject: [patch, fortran] PR46331 Compilation time long with simple function in array constructor
The problem here is that we are expanding a large array constructor that
contains a function that does not reduce (ie. rand(0)). The solution is a small
adjustment to gfc_is_constant_expr which is used to determine whether or not to
expand a constructor. In this case, simply treating an non pure function as not
For the test case, without the patch, compile time is approximately 19 seconds.
With the patch, compilation is about 0.1 seconds.
I don't think a new test case is needed.
Ok for trunk?
2010-11-07 Jerry DeLisle <firstname.lastname@example.org>
* expr.c (gfc_is_constant_expr): Treat intrinsic functions that are not
pure as not constant.
--- expr.c (revision 166382)
+++ expr.c (working copy)
@@ -923,7 +923,8 @@ gfc_is_constant_expr (gfc_expr *e)
/* Call to intrinsic with at least one argument. */
- if (e->value.function.isym && e->value.function.actual)
+ if (e->symtree && e->symtree->n.sym->attr.pure
+ && e->value.function.isym && e->value.function.actual)
for (arg = e->value.function.actual; arg; arg = arg->next)
if (!gfc_is_constant_expr (arg->expr))