This is the mail archive of the mailing list for the GCC 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, fortran] PR46331 Compilation time long with simple function in array constructor

Hi all,

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 constant.

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 <>

	PR fortran/46331
	* expr.c (gfc_is_constant_expr): Treat intrinsic functions that are not
	pure as not constant.
Index: expr.c
--- expr.c	(revision 166382)
+++ expr.c	(working copy)
@@ -923,7 +923,8 @@ gfc_is_constant_expr (gfc_expr *e)
 	return 1;
       /* 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))

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