[Bug fortran/46331] Compilation time long with simple function in array constructor

2010-11-09 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46331

--- Comment #4 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2010-11-10 
04:58:23 UTC ---
Author: jvdelisle
Date: Wed Nov 10 04:58:16 2010
New Revision: 166520

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=166520
Log:
2010-11-09  Jerry DeLisle  jvdeli...@gcc.gnu.org
Mikael Morin   mik...@gcc.gnu.org

PR fortran/46331
* intrinsic.c: Correctly set the pure attributes for intrinsic
functions.
* expr.c (check_specification_function): Remove this function and move
its code into gfc_is_constant_expr. (gfc_is_constant_expr): Change the
order of checks by checking for non-constant arguments first.  Then,
check for initialization functions, followed by intrinsics.

Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/fortran/intrinsic.c


[Bug fortran/46331] Compilation time long with simple function in array constructor

2010-11-09 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46331

Jerry DeLisle jvdelisle at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED

--- Comment #5 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2010-11-10 
05:25:59 UTC ---
Fixed on trunk.


[Bug fortran/46331] Compilation time long with simple function in array constructor

2010-11-07 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46331

--- Comment #2 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2010-11-07 
14:32:47 UTC ---
Patch: The part removed too agressively decides if an expression is constant. 
In the case of rand(), the result obviously does not reduce to a constant but
the array constructor was expanded.  Returning zero here means the function is
not constant and therefore the array is not expanded at compile time.

Regression tested OK on x86-64.

Index: expr.c
===
--- expr.c(revision 166382)
+++ expr.c(working copy)
@@ -900,7 +900,6 @@ int
 gfc_is_constant_expr (gfc_expr *e)
 {
   gfc_constructor *c;
-  gfc_actual_arglist *arg;

   if (e == NULL)
 return 1;
@@ -921,19 +920,8 @@ gfc_is_constant_expr (gfc_expr *e)
   /* Specification functions are constant.  */
   if (check_specification_function (e) == MATCH_YES)
 return 1;
+  return 0;

-  /* Call to intrinsic with at least one argument.  */
-  if (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))
-  return 0;
-
-  return 1;
-}
-  else
-return 0;
-
 case EXPR_CONSTANT:
 case EXPR_NULL:
   return 1;


[Bug fortran/46331] Compilation time long with simple function in array constructor

2010-11-07 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46331

Jerry DeLisle jvdelisle at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2010.11.08 02:19:56
 AssignedTo|unassigned at gcc dot   |jvdelisle at gcc dot
   |gnu.org |gnu.org
 Ever Confirmed|0   |1

--- Comment #3 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2010-11-08 
02:19:56 UTC ---
I have a better patch and will submit it for approval.


[Bug fortran/46331] Compilation time long with simple function in array constructor

2010-11-06 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46331

--- Comment #1 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2010-11-06 
16:09:30 UTC ---
I should add that if rand is the only function that acts like this, then this
is not of much value.  While just playing around, this translates as expected.
(Nice short -fdump-tree-original file.)

program foo
implicit none

Integer :: i
Integer, Parameter :: N = 10**4
Real, Dimension(N) :: xs

! Random points
!xs = (/ (rand(0), i=1,N) /)
xs = (/ (myfunction(0), i=1,N) /)
!xs = myfunction (0.0)
print *, xs
contains
  function myfunction(somenumber)
integer :: somenumber
real :: myfunction
myfunction = 1234.567
if (somenumber .eq. 42) return
myfunction = somenumber + rand(0)
  end function
end program