This is the mail archive of the
mailing list for the GCC project.
Re: missed optimization
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>, fortran at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Tue, 29 Sep 2015 21:26:25 +0200
- Subject: Re: missed optimization
- Authentication-results: sourceware.org; auth=none
- References: <20150929183645 dot GA86538 at troutmask dot apl dot washington dot edu>
integer i, j
i = 2
j = 4
n = i**j ! <-- This should evaluate to 16 without a function call.
end subroutine foo
To do this in the Fortran front end would require constant propagation,
which we currently do not do.
We do not do this because the general case would be quite hard without
doing the same kind of thing the middle end does - splitting into
basic blocks, converting to single static assignment, etc.
I suspect the best way would be to teach the back end about how
Fortran's library functions behave with constant arguments. This
would sort of duplicate simplification, but could still be
We could implement this as a Fortran-specific pass to be called
after constant propagation.