public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57160] New: short-circuit IF only with -ffrontend-optimize
@ 2013-05-03 12:41 Joost.VandeVondele at mat dot ethz.ch
2013-05-04 19:23 ` [Bug fortran/57160] " burnus at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2013-05-03 12:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57160
Bug #: 57160
Summary: short-circuit IF only with -ffrontend-optimize
Classification: Unclassified
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: Joost.VandeVondele@mat.ethz.ch
it would be nice to have the short-circuit evaluation of IF statements only if
-ffrontend-optimize is in place. It would help to capture (at -O0) bugs like:
MODULE M1
TYPE T1
LOGICAL :: T=.TRUE.
END TYPE T1
CONTAINS
SUBROUTINE S1(m)
TYPE(T1), POINTER :: m
IF (ASSOCIATED(m) .AND. m%T) THEN
WRITE(6,*) "X"
ENDIF
END SUBROUTINE
END MODULE
USE M1
TYPE(T1), POINTER :: m=>NULL()
CALL S1(m)
END
where I would like the code to segfault.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/57160] short-circuit IF only with -ffrontend-optimize
2013-05-03 12:41 [Bug fortran/57160] New: short-circuit IF only with -ffrontend-optimize Joost.VandeVondele at mat dot ethz.ch
@ 2013-05-04 19:23 ` burnus at gcc dot gnu.org
2013-07-21 21:08 ` tkoenig at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-05-04 19:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57160
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-05-04 19:23:08 UTC ---
GCC (the middle end) has TRUTH_AND_EXPR (matching Fortran's .AND.) and
TRUTH_ANDIF_EXPR (matching C's &&) - besides the IAND/& which is BIT_AND_EXPR.
Currently, the code generation directly translates all .AND. into
TRUTH_AND_EXPR. Hence, the middle end/target-code generation might decide to
evaluate "A.AND.B" as "A andif B", "B andif A" or both as "A and B". That's
really outside the scope of the Fortran front end.
What you would like is that both A and B are /always/ evaluated with .AND.
That's quite some work with little gain. As I know for experience, the current
TRUTH_AND_EXPR does no short-circuit evaluation in the given order - I already
had segfaults for code similar to your's.
* * *
As a side note, see http://www.j3-fortran.org/doc/year/13/13-234.txt for a
proposal for the next Fortran standard which allows to explicitly require
short-circuit evaluation, using:
if ( IF (ASSOCIATED(m)) THEN (m%T) ELSE (.false.) ) then
write (6,*) s1(m)
end if
Or even as:
write (6,*) IF (ASSOCIATED(m)) THEN ( IF(m%T)then("X")ELSE("") ) ELSE ("")
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/57160] short-circuit IF only with -ffrontend-optimize
2013-05-03 12:41 [Bug fortran/57160] New: short-circuit IF only with -ffrontend-optimize Joost.VandeVondele at mat dot ethz.ch
2013-05-04 19:23 ` [Bug fortran/57160] " burnus at gcc dot gnu.org
@ 2013-07-21 21:08 ` tkoenig at gcc dot gnu.org
2014-12-21 15:18 ` dominiq at lps dot ens.fr
2014-12-22 7:12 ` Joost.VandeVondele at mat dot ethz.ch
3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-07-21 21:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57160
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tkoenig at gcc dot gnu.org
--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I would really prefer if there was a compile-time warning for
IF (ASSOCIATED(m) .AND. m%T) THEN
which might be doable.
Same thing for
if (x /= 0 .and. 2/x > 0) then
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/57160] short-circuit IF only with -ffrontend-optimize
2013-05-03 12:41 [Bug fortran/57160] New: short-circuit IF only with -ffrontend-optimize Joost.VandeVondele at mat dot ethz.ch
2013-05-04 19:23 ` [Bug fortran/57160] " burnus at gcc dot gnu.org
2013-07-21 21:08 ` tkoenig at gcc dot gnu.org
@ 2014-12-21 15:18 ` dominiq at lps dot ens.fr
2014-12-22 7:12 ` Joost.VandeVondele at mat dot ethz.ch
3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-12-21 15:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57160
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2014-12-21
Ever confirmed|0 |1
--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Is there still some interest for this PR?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/57160] short-circuit IF only with -ffrontend-optimize
2013-05-03 12:41 [Bug fortran/57160] New: short-circuit IF only with -ffrontend-optimize Joost.VandeVondele at mat dot ethz.ch
` (2 preceding siblings ...)
2014-12-21 15:18 ` dominiq at lps dot ens.fr
@ 2014-12-22 7:12 ` Joost.VandeVondele at mat dot ethz.ch
3 siblings, 0 replies; 5+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2014-12-22 7:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57160
Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
CC| |Joost.VandeVondele at mat dot ethz
| |.ch
--- Comment #4 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> ---
(In reply to Dominique d'Humieres from comment #3)
> Is there still some interest for this PR?
Yes, seems still nice.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-22 7:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-03 12:41 [Bug fortran/57160] New: short-circuit IF only with -ffrontend-optimize Joost.VandeVondele at mat dot ethz.ch
2013-05-04 19:23 ` [Bug fortran/57160] " burnus at gcc dot gnu.org
2013-07-21 21:08 ` tkoenig at gcc dot gnu.org
2014-12-21 15:18 ` dominiq at lps dot ens.fr
2014-12-22 7:12 ` Joost.VandeVondele at mat dot ethz.ch
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).