public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46331] New: Compilation time long with simple function in array constructor
@ 2010-11-06 15:30 jvdelisle at gcc dot gnu.org
2010-11-06 16:09 ` [Bug fortran/46331] " jvdelisle at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2010-11-06 15:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46331
Summary: Compilation time long with simple function in array
constructor
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jvdelisle@gcc.gnu.org
program foo
implicit none
Integer :: i
Integer, Parameter :: N = 10**4
Real, Dimension(N) :: xs
! Random points
xs = (/ (rand(0), i=1,N) /)
print *, xs
end program
The time spent in the FE is not bad, but the resulting translation is horrible
and it wreaks havoc with the middle end and down the road.
I think we should not expand this constructor at all, especially since 'i' is
not used in the function expression. However, rand(0) needs to be called once
for each element. That means it needs to be translated into:
do i-1,N
xs = rand(0)
end do
In otherwords, I think another special case in gfc_trans_assignment. There are
other special cases already there.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/46331] Compilation time long with simple function in array constructor
2010-11-06 15:30 [Bug fortran/46331] New: Compilation time long with simple function in array constructor jvdelisle at gcc dot gnu.org
@ 2010-11-06 16:09 ` jvdelisle at gcc dot gnu.org
2010-11-07 14:33 ` jvdelisle at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2010-11-06 16:09 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/46331] Compilation time long with simple function in array constructor
2010-11-06 15:30 [Bug fortran/46331] New: Compilation time long with simple function in array constructor jvdelisle at gcc dot gnu.org
2010-11-06 16:09 ` [Bug fortran/46331] " jvdelisle at gcc dot gnu.org
@ 2010-11-07 14:33 ` jvdelisle at gcc dot gnu.org
2010-11-08 2:20 ` jvdelisle at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2010-11-07 14:33 UTC (permalink / raw)
To: gcc-bugs
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;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/46331] Compilation time long with simple function in array constructor
2010-11-06 15:30 [Bug fortran/46331] New: Compilation time long with simple function in array constructor jvdelisle at gcc dot gnu.org
2010-11-06 16:09 ` [Bug fortran/46331] " jvdelisle at gcc dot gnu.org
2010-11-07 14:33 ` jvdelisle at gcc dot gnu.org
@ 2010-11-08 2:20 ` jvdelisle at gcc dot gnu.org
2010-11-10 4:58 ` jvdelisle at gcc dot gnu.org
2010-11-10 5:26 ` jvdelisle at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2010-11-08 2:20 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/46331] Compilation time long with simple function in array constructor
2010-11-06 15:30 [Bug fortran/46331] New: Compilation time long with simple function in array constructor jvdelisle at gcc dot gnu.org
` (2 preceding siblings ...)
2010-11-08 2:20 ` jvdelisle at gcc dot gnu.org
@ 2010-11-10 4:58 ` jvdelisle at gcc dot gnu.org
2010-11-10 5:26 ` jvdelisle at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2010-11-10 4:58 UTC (permalink / raw)
To: gcc-bugs
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=gcc&view=rev&rev=166520
Log:
2010-11-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Mikael Morin <mikael@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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/46331] Compilation time long with simple function in array constructor
2010-11-06 15:30 [Bug fortran/46331] New: Compilation time long with simple function in array constructor jvdelisle at gcc dot gnu.org
` (3 preceding siblings ...)
2010-11-10 4:58 ` jvdelisle at gcc dot gnu.org
@ 2010-11-10 5:26 ` jvdelisle at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2010-11-10 5:26 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-11-10 5:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-06 15:30 [Bug fortran/46331] New: Compilation time long with simple function in array constructor jvdelisle at gcc dot gnu.org
2010-11-06 16:09 ` [Bug fortran/46331] " jvdelisle at gcc dot gnu.org
2010-11-07 14:33 ` jvdelisle at gcc dot gnu.org
2010-11-08 2:20 ` jvdelisle at gcc dot gnu.org
2010-11-10 4:58 ` jvdelisle at gcc dot gnu.org
2010-11-10 5:26 ` jvdelisle at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).