This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR 57160: short-circuit IF only with -ffrontend-optimize
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Dominique d'Humières <dominiq at lps dot ens dot fr>, Adam Hirst <adam at aphirst dot karoo dot co dot uk>, gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>, VandeVondele Joost <Joost dot VandeVondele at mat dot ethz dot ch>
- Date: Tue, 24 Jul 2018 18:18:40 +0200
- Subject: Re: [Patch, Fortran] PR 57160: short-circuit IF only with -ffrontend-optimize
- References: <D5E8D1C6-CC0E-4EA8-A5C0-EF581D0399A0@lps.ens.fr> <CAKwh3qiETg4zjTpr4+JE8uV+Uu8rZXUqjfp_rfuh82SKd_oTSw@mail.gmail.com> <CAO9iq9EBNkUxWHSPFWH5Ag0Y3C5W4hkf0V=1oTj-0fLCf+CN+Q@mail.gmail.com>
2018-07-24 17:41 GMT+02:00 Janne Blomqvist <blomqvist.janne@gmail.com>:
> Optimization bugs that pop up at different optimization levels are hard
> enough for users to figure out
Right, and they're impossible to detect if there is no way to disable
the optimization, which is what this PR is about.
> without the frontend generating different
> code to begin with depending on the optimization level.
In the end it doesn't make much of a difference whether the
optimizations are done in the front or the middle end. The user knows
nothing about this, and he doesn't need to.
The problematic point here is that short-circuiting is an optimization
that is enabled already at -O0.
> Also, with a
> separate option it would be easy to check how it affects performance at
> different optimization levels.
For the case at hand, the short-circuiting is an absolutely valid
optimization. There is no reason why you wouldn't wanna do it (with -O
flags).
> What about making it a -fcheck=short-circuit-logicals (or however you want
> to spell it?) option, that also would be enabled with -fcheck=all?
What would such a flag even do? The actually invalid operation in the
test case is a null-pointer access, which could be caught by
-fcheck=pointer if we disable the optimization that removes it (i.e.
short-circuiting).
However, it also seems like -fcheck=pointer could use some
enhancement, since it does not even seem to catch simple cases like
this:
integer, pointer :: p => null()
print *,p
end
Cheers,
Janus